W dniu 24.03.2016 o 18:46, Mark Foley pisze: > I've just joined the maillist and would like to create some local, custom > rules, > possibly sharable if they work out. I've only briefly looked at the rule XML > file and the and it appears mostly to be a pattern matcher with > wrong-phrase/correct-phrase. > > Can such a tool do generic tense agreement such as: > > I go to the store and I bought milk. ("go" present, "bought" past) > I am went ... > > The out-of-the-box LanguageTool doesn't catch these. > > If the Rule Editor is not appropriate for this sort of thing, is there another > mechanism?
Rule Editor is appropriate but you need to look at Tips & Tricks: http://wiki.languagetool.org/tips-and-tricks You need to use skipping from the first verb token (with postag that matches a regular expression "VB[PZ]?") to the VBD token. Roughly this rule would do: <rule id="INCORRECT_TENSE" name="Incorrect tense"> <pattern> <marker> <token postag='VB[PZ]?' postag_regexp='yes' skip='-1'></token> </marker> <token postag='VBD'></token> </pattern> <message>Use past tense here: <suggestion><match no="1" postag="VBD"/></suggestion>.</message> <example correction='went'>I <marker>go</marker> to the store and I bought milk.</example> <example>I went to the store and I bought milk.</example> </rule> However, you will almost surely get false alarms this way: She failed and felt humiliated . tatoeba, Analyse Leagues came and went . wikipedia, Analyse The hat got wet and went limp . tatoeba, Analyse Off it went . tatoeba, Analyse He felt tired . tatoeba, Analyse Prices went up . tatoeba, Analyse Tom felt tired . tatoeba, Analyse Tom felt humiliated . tatoeba, Analyse Tom felt relieved . tatoeba, Analyse Tom felt persecuted . tatoeba, Analyse Tom felt frustrated . tatoeba, Analyse Tom felt confused . tatoeba, Analyse Mary felt excluded . tatoeba, Analyse We broke up and went our own ways . tatoeba, Analyse It began to rain and she got wet . tatoeba, Analyse Mr Hobson shut the shop and went home . tatoeba, Analyse It was so hot that we went swimming . tatoeba, Analyse Tim settled down after he got married . tatoeba, Analyse Down it came and away went the day . tatoeba, Analyse He shut the door and went upstairs . tatoeba, Analyse He bade us farewell , and went away . tatoeba, Analyse He got hurt when he fell down . tatoeba, Analyse He hurt his left foot when he fell . tatoeba, Analyse He went mad when he heard the story . tatoeba, Analyse She put on her coat and went out . tatoeba, Analyse She looked upset as she read the letter . tatoeba, Analyse She shut the door and went upstairs . tatoeba, Analyse She threw on a coat and went . tatoeba, Analyse She fell down and broke her left leg . tatoeba, Analyse She fell down and broke her left leg . tatoeba, Analyse Lincoln was sad that he had not won . tatoeba, Analyse I did so much that I felt tired . tatoeba, Analyse Kelly cut physical education and went home . tatoeba, Analyse Bob went out before I knew it . tatoeba, Analyse Silver was often found alloyed with gold . wikipedia, Analyse Candidates traded blows over the proposed tax cut . tatoeba, Analyse Left alone , she felt very tired . tatoeba, Analyse It was clear that he went there . tatoeba, Analyse It began to rain when he went out . tatoeba, Analyse She went to rehab and straightened herself out . tatoeba, Analyse The old woman got hurt when she fell . tatoeba, Analyse I screwed up my courage and went there . tatoeba, Analyse I mustered up my courage and went there . tatoeba, Analyse Tom put his hat on and went outside . tatoeba, Analyse I thought that book was difficult to read . tatoeba, Analyse I ate a large dinner and felt satisfied . tatoeba, Analyse He stood up when I went in . tatoeba, Analyse I ate fried rice and drank some beer . tatoeba, Analyse Did you read the book I gave you ? tatoeba, Analyse What was the last concert you went to ? tatoeba, Analyse I went out even though it was raining . tatoeba, Analyse I won ' t let anyone hurt you . tatoeba, Analyse First of all, you need to make sure that no form on token 1 is also VBD ('felt'). Second, felt +VBD/VBN should be disambiguated but is not (yet). So writing complex rules might require adding more disambiguation or lots of exceptions. I can help. Third, you need to look at some connectives (such as 'when') that require a different tense. Add them as exceptions with the scope="next" on the first token. I added some easy exceptions to the initial rule: <!-- English rule, 2016-03-24 --> <rule id="INCORRECT_TENSE" name="Incorrect tense"> <pattern> <marker> <token postag='VB[PZ]?' postag_regexp='yes' skip='-1'><exception postag='VBD'></exception><exception postag='SENT_START|TO' postag_regexp='yes' scope='previous'></exception></token> </marker> <token postag='VBD'></token> </pattern> <message>Use past tense here: <suggestion><match no="1"/></suggestion>.</message> <example correction=''>I <marker>go</marker> to the store and I bought milk.</example> <example>I went to the store and I bought milk.</example> </rule> And the number of false alarms went down immediately: We broke up and went our own ways . tatoeba, Analyse It was so hot that we went swimming . tatoeba, Analyse Tim settled down after he got married . tatoeba, Analyse He bade us farewell , and went away . tatoeba, Analyse He went mad when he heard the story . tatoeba, Analyse She threw on a coat and went . tatoeba, Analyse She fell down and broke her left leg . tatoeba, Analyse Lincoln was sad that he had not won . tatoeba, Analyse Candidates traded blows over the proposed tax cut . tatoeba, Analyse It was clear that he went there . tatoeba, Analyse I screwed up my courage and went there . tatoeba, Analyse I mustered up my courage and went there . tatoeba, Analyse I thought that book was difficult to read . tatoeba, Analyse He stood up when I went in . tatoeba, Analyse I ate fried rice and drank some beer . tatoeba, Analyse What was the last concert you went to ? tatoeba, Analyse I went out even though it was raining . tatoeba, Analyse These would require a lot of disambiguation (you'll see which words are matched, and this surely is not how it should work). Best, Marcin ------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140 _______________________________________________ Languagetool-devel mailing list Languagetool-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/languagetool-devel