Daniel Nab er  wrote:

> Hi,
>
> I've implemented a 'filter' element for XML which can be used to modify,
> keep, or reject a rule match. The first use case is a rule that checks
> if a weekday matches its date, e.g. "Monday, 7 October 2014" is
> inconsistent, as 2014-10-07 is not a Monday. The rule for that looks
> like this:
>
>      <pattern>
>          <token regexp="yes">&weekdays;</token>
>          <token>,</token>
>          <token regexp="yes">\d\d?</token>
>          <token regexp="yes">&months;|&abbrevMonths;</token>
>          <token regexp="yes">\d\d\d\d</token>
>      </pattern>
>      <filter class="org.languagetool.rules.en.DateCheckFilter"
> args="year:\5 month:\4 day:\3 weekDay:\1"/>
>      <message>The date \3 \4 \5 is not a \1.</message>
>
> The 'class' attribute refers to a Java class that implements the new
> RuleFilter interface. If this rule matches, the filter gets called with
> the 'args' attribute. Those "\5" etc. are actually the same items as in
> the message: they get replaced with the actual tokens that match the
> pattern. The rule filter can then modify the RuleMatch object or not, or
> it can return null. Returning null means that the rule match will be
> ignored. So this rule matches all dates of this format, and only keeps
> those rule matches where weekday and date do not match.
>
> &weekdays;, &months;, and &abbrevMonths; are just XML entities that get
> expanded to "Monday|Tuesday|..." etc.
>
> Please extend AbstractDateCheckFilter for your language and add rules to
> your grammar.xml if you want this check for your language.
>
> If you have ideas how to implement this in a more clever way, or other
> comments, please let me know.


Hi Daniel

In Esperanto and Breton, the day of the month is often written
with letters rather than a number.  It would like like saying
"Saturday thirteen" instead of "Saturday 13".   I don't think
that LT date checker supports that without changing
languagetool-core/src/main/java/org/languagetool/rules/AbstractDateCheckFilter.java

Regards
Dominique

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Languagetool-devel mailing list
Languagetool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-devel

Reply via email to