Hi,

Dominique had the idea to check dates to make sure the day of the week 
is plausible:
https://github.com/languagetool-org/languagetool/issues/116

Here's an idea how this could be implemented: extend the rule syntax 
with a "modify" element that specifies a Java class. This class needs to 
implement a simple interface. The method in the Java class will only be 
called if the rule matches. The method is called with the matching 
sentence, the match position, the RuleMatch objects, and optionally 
other parameters. It can then remove rule matches, add matches, or 
modify them. The pattern for checking a date could look like this:

<pattern>
        <token 
regexp="yes">Saturday|Sunday|Monday|Tuesday|Wednesday|Thursday|Friday</token>
        <token>,</token>
        <token regexp="yes">\d+{4}-\d+{2}-\d+{2}</token>
</pattern>
<modify 
class="org.languagetool.rules.patterns.modifier.DateAndDayOfWeek" />
<message>Date and day of week do not match</message>
<example type="incorrect">On <marker>Saturday</marker>, 
2014-06-08</example>
<example type="correct">On <marker>Sunday</marker>, 2014-06-08</example>

The Java rule would then need to parse the date (yes, that's some amount 
of duplication) and keep the rule match only if the day of week doesn't 
match the date.

What I like about this approach is that it might me used to extend rules 
without the need to touch the rule syntax. It is not meant to become a 
common case, however, standard rule matching should still be enough for 
 >95% of all cases.

What do you think?

Regards
  Daniel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Languagetool-devel mailing list
Languagetool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-devel

Reply via email to