Skip to content

Commit

Permalink
Merge pull request #17 from zoho/hawking_dev
Browse files Browse the repository at this point in the history
Hawking Parser Enhancements and Bug Fixes
  • Loading branch information
ArulVendhan authored May 27, 2021
2 parents 931ed76 + 8a0188a commit 3847c56
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
package com.zoho.hawking.datetimeparser.components;

import com.zoho.hawking.datetimeparser.DateAndTime;
import com.zoho.hawking.datetimeparser.constants.ConfigurationConstants;
import com.zoho.hawking.datetimeparser.constants.PrepositionConstants;
import com.zoho.hawking.datetimeparser.utils.NumberParser;
import com.zoho.hawking.datetimeparser.utils.PrepositionParser;
import com.zoho.hawking.datetimeparser.utils.TagParser;
Expand Down Expand Up @@ -123,21 +125,21 @@ private void findPrefixAndTenseIndicator() {

private void prefixProcessing() {
//TODO
// if (PrepositionConstants.FEW.getWord().equals(secondaryPrefix)) {
// number = ConfigurationConstants.getConfiguration().getRangeDefault().getFew();
// isNumberPresent = true;
// }
if (PrepositionConstants.FEW.getWord().equals(secondaryPrefix)) {
number = ConfigurationConstants.getConfiguration().getRangeDefault().getFew();
isNumberPresent = true;
}
}

HashMap<String, String> getTagMap() {
return mapTags;
}

void findSpanRange() {
// if (!dateAndTime.getPreviousDependency().equals("")) {
// sentenceTense = "PRESENT"; //No I18N
// tenseIndicator = "";
// }
if (!dateAndTime.getPreviousDependency().equals("")) {
sentenceTense = "PRESENT"; //No I18N
tenseIndicator = "";
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import com.zoho.hawking.datetimeparser.DateAndTime;
import com.zoho.hawking.datetimeparser.constants.ConfigurationConstants;
import com.zoho.hawking.datetimeparser.constants.PrepositionConstants;
import com.zoho.hawking.language.AbstractLanguage;
import com.zoho.hawking.language.english.DateTimeWordProperties;
import com.zoho.hawking.datetimeparser.utils.DateTimeManipulation;
Expand Down Expand Up @@ -71,13 +72,13 @@ public void computeNumber() {
//in last year last month,last month refers to 12th month of the year
//in order to distinguish between last month and last year last month this check is done
//TODO
// if (!isSet && dateAndTime.getPreviousDependency().equals(Constants.YEAR_SPAN_TAG)) {
// if (tenseIndicator.equals(PrepositionConstants.LAST.getWord())) {
// isOrdinal = true;
// isNumberPresent = true;
// nthMonthOfYear = 12;
// }
// }
if (!isSet && dateAndTime.getPreviousDependency().equals(Constants.YEAR_SPAN_TAG)) {
if (tenseIndicator.equals(PrepositionConstants.LAST.getWord())) {
isOrdinal = true;
isNumberPresent = true;
nthMonthOfYear = 12;
}
}

if (isExactTimeSpan && isNumberPresent) {
isDatePresent = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void present() {
} else if (super.abstractLanguage.weekendWords.contains(timeSpan)) {
dateAndTime.setDateAndTime(DateTimeManipulation.addWeeks(dateAndTime.getDateAndTime(), number, 0).
dayOfWeek().setCopy(ConfigurationConstants.getConfiguration().getWeekDayAndEnd().getWeekEndStart()));
startWeekIncrement = (number - 1);
startWeekIncrement = number != 0 ? (number - 1) : 0;
endDaysIncrement = ConfigurationConstants.getConfiguration().getWeekDayAndEnd().getWeekEndDiff();
DateTimeManipulation.setWeekStartAndEndTime(dateAndTime, startWeekIncrement, 0, 0, endDaysIncrement, 1, 2);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/zoho/hawking/language/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Utils {
public static List<String> createDateWithoutAnyOneOfTheRange(WordImplication wordImplication, WordProperty[] allWords) {
ArrayList<String> wordList = new ArrayList<>();
for (WordProperty word : allWords) {
if (word.getTense() != null && word.getTense().getValue() <= wordImplication.getValue() && word.getTense().getValue() >= wordImplication.getValue() && word.isAnyRangeNotApplicable()) {
if (word.getWordImplication() != null && word.getWordImplication().getValue() <= wordImplication.getValue() && word.getWordImplication().getValue() >= wordImplication.getValue() && word.isAnyRangeNotApplicable()) {
wordList.add(word.getWord());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void setReferenceTime(DateTime referenceTime) {
}

public void cleanParsedText(String wordToRemove) {
this.parsedText = parsedText.replace(wordToRemove, "");
this.parsedText = parsedText.replaceFirst("^"+wordToRemove, "");
}
private static Long getStartTimeInLong(List<ParserOutput> datesFound, int index) {
DateTime startDate = datesFound.get(index).getDateRange().getStart();
Expand Down
Binary file modified src/main/resources/parser/parser.crf.ser.gz
Binary file not shown.

0 comments on commit 3847c56

Please sign in to comment.