diff --git a/src/main/java/com/zoho/hawking/datetimeparser/components/DateTimeComponent.java b/src/main/java/com/zoho/hawking/datetimeparser/components/DateTimeComponent.java index 57c1140..f72d3fe 100755 --- a/src/main/java/com/zoho/hawking/datetimeparser/components/DateTimeComponent.java +++ b/src/main/java/com/zoho/hawking/datetimeparser/components/DateTimeComponent.java @@ -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; @@ -123,10 +125,10 @@ 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 getTagMap() { @@ -134,10 +136,10 @@ HashMap getTagMap() { } void findSpanRange() { -// if (!dateAndTime.getPreviousDependency().equals("")) { -// sentenceTense = "PRESENT"; //No I18N -// tenseIndicator = ""; -// } + if (!dateAndTime.getPreviousDependency().equals("")) { + sentenceTense = "PRESENT"; //No I18N + tenseIndicator = ""; + } } diff --git a/src/main/java/com/zoho/hawking/datetimeparser/components/MonthParser.java b/src/main/java/com/zoho/hawking/datetimeparser/components/MonthParser.java index 961d73d..9c20a1b 100755 --- a/src/main/java/com/zoho/hawking/datetimeparser/components/MonthParser.java +++ b/src/main/java/com/zoho/hawking/datetimeparser/components/MonthParser.java @@ -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; @@ -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; diff --git a/src/main/java/com/zoho/hawking/datetimeparser/components/WeekParser.java b/src/main/java/com/zoho/hawking/datetimeparser/components/WeekParser.java index d6ed38c..718097f 100755 --- a/src/main/java/com/zoho/hawking/datetimeparser/components/WeekParser.java +++ b/src/main/java/com/zoho/hawking/datetimeparser/components/WeekParser.java @@ -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 { diff --git a/src/main/java/com/zoho/hawking/language/Utils.java b/src/main/java/com/zoho/hawking/language/Utils.java index 1ca5aba..f2b4b31 100755 --- a/src/main/java/com/zoho/hawking/language/Utils.java +++ b/src/main/java/com/zoho/hawking/language/Utils.java @@ -13,7 +13,7 @@ public class Utils { public static List createDateWithoutAnyOneOfTheRange(WordImplication wordImplication, WordProperty[] allWords) { ArrayList 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()); } } diff --git a/src/main/java/com/zoho/hawking/utils/DateTimeProperties.java b/src/main/java/com/zoho/hawking/utils/DateTimeProperties.java index d23bc68..24d40e5 100755 --- a/src/main/java/com/zoho/hawking/utils/DateTimeProperties.java +++ b/src/main/java/com/zoho/hawking/utils/DateTimeProperties.java @@ -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 datesFound, int index) { DateTime startDate = datesFound.get(index).getDateRange().getStart(); diff --git a/src/main/resources/parser/parser.crf.ser.gz b/src/main/resources/parser/parser.crf.ser.gz index 216dd5c..a2c3a6a 100644 Binary files a/src/main/resources/parser/parser.crf.ser.gz and b/src/main/resources/parser/parser.crf.ser.gz differ