Package org.languagetool.rules
Class AbstractDateCheckWithSuggestionsFilter
java.lang.Object
org.languagetool.rules.patterns.RuleFilter
org.languagetool.rules.AbstractDateCheckWithSuggestionsFilter
- Direct Known Subclasses:
DateCheckFilter,DateCheckFilter,DateCheckFilter,DateCheckFilter,DateCheckFilter,DateCheckFilter,DateCheckFilter
Accepts rule matches if a date doesn't match the accompanying weekday, e.g. if
Monday, 8 November 2003
isn't actually a Monday. Replaces {realDay} with the real day of the date in the rule's message,
and {day} with the claimed day from the text (might be useful in case the text uses an abbreviation).- Since:
- 2.7
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacceptRuleMatch(RuleMatch match, Map<String, String> args, int patternTokenPos, AnalyzedTokenReadings[] patternTokens, List<Integer> tokenPositions) Returns the original rule match or a modified one, ornullif the rule match is filtered out.protected StringadjustSuggestion(String sugg) private StringfindNewDayOfMonth(int day, int month, int year, int dayOfWeekFromString) protected abstract Calendarprotected CalendargetDate(int dayOfMonth, int month, int year) protected intgetDayOfMonth(String localizedDayOfMonth) Implement so that "first" returns1, second returns2etc.private intgetDayOfMonthFromStr(String dayOfMonthString) protected abstract intgetDayOfWeek(String localizedWeekDayString) Implement so that Sunday returns1, Monday2etc.protected abstract StringgetDayOfWeek(Calendar date) Get the localized name of the day of week for the given date.private intgetDayOfWeekFromDate(Calendar dateFromDate) protected StringgetDayStrLikeOriginal(String day, String original) protected abstract Stringprotected abstract intImplement so that January returns1, February2etc.private intgetMonthFromStr(String monthStr) private intgetYearFromStr(String yearArg) Methods inherited from class org.languagetool.rules.patterns.RuleFilter
getLanguageFromRuleMatch, getOptional, getOptional, getPosition, getRequired, getSkipCorrectedReference, getSynthesizerFromRuleMatch, isMatchAtSentenceStart, matches
-
Field Details
-
DAY_OF_MONTH_PATTERN
-
-
Constructor Details
-
AbstractDateCheckWithSuggestionsFilter
public AbstractDateCheckWithSuggestionsFilter()
-
-
Method Details
-
getDayOfWeek
Implement so that Sunday returns1, Monday2etc.- Parameters:
localizedWeekDayString- a week day name or abbreviation thereof
-
getDayOfWeek
Get the localized name of the day of week for the given date. -
getDayOfMonth
Implement so that "first" returns1, second returns2etc.- Parameters:
localizedDayOfMonth- name of day of the month or abbreviation thereof
-
getMonth
Implement so that January returns1, February2etc.- Parameters:
localizedMonth- name of a month or abbreviation thereof
-
getCalendar
-
getErrorMessageWrongYear
-
acceptRuleMatch
public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> args, int patternTokenPos, AnalyzedTokenReadings[] patternTokens, List<Integer> tokenPositions) Description copied from class:RuleFilterReturns the original rule match or a modified one, ornullif the rule match is filtered out.- Specified by:
acceptRuleMatchin classRuleFilter- Parameters:
args- a map with values foryear,month,day(day of month),weekDaypatternTokens- those tokens of the text that correspond the matched pattern- Returns:
nullif this rule match should be removed, or any other RuleMatch (e.g. the one from the arguments) that properly describes the detected error
-
findNewDayOfMonth
-
getDayOfWeekFromDate
-
getDate
-
getYearFromStr
-
getDayOfMonthFromStr
-
getMonthFromStr
-
getDayStrLikeOriginal
-
adjustSuggestion
-