Hi, I am trying to write a rule that will catch discrepancies between articulated prepositions and nouns in Italian (for instance masculine followed by feminine or singular followed by plural). I have written a simple rule using the basic editor:
Basically, you could use the online rule creator to make a rule for each case you want to cover, copy them to a text file, remove the ids, and add <rulegroup id="TEST" name="test"> above and the closing tag </rulegroup> below.
EDIT: Corrected indentation. Thanks, Daniel.
Also, note that in the second pattern, I abbreviated the notation and made it <token postag='ARTPRE-M:s' /> I find that a lot easier to read and it is well-formed XML, but it’s a matter of taste.
thank you very much for your help. I think I now know how to use the rulegroup system. However, the “Check XML” function throws an error (even to the code you suggested): Error: Found 4 rules in XML - please specify only one rule in your XML
Perhaps this happens because rulegroups are not supported by the XML check function, but how can I proceed from here? For instance for checking the rule against the corpus of sentences?
Indeed, the online check cannot work on <rulegroup>, you’d have to test the <rule>s inside the <rulegroup> one by one if you want to use the online checker.
I have grouped the rules and analyzed them separately. Below is the complete rule, with a request for help at the end about avoiding a specific type of false positives:
<rulegroup id="ConcordanzaPreposizioneArticolata-Sostantivo" name="Concordanza preposizione articolata - sostantivo">
<rule>
<pattern>
<token postag='ARTPRE-M:p'></token>
<token postag='NOUN-M:s'></token>
</pattern>
<message>La preposizione articolata non concorda con il sostantivo che la segue</message>
<example type="correct">Il libro <marker>degli amici</marker>.</example>
<example type="incorrect">Il libro <marker>degli amico</marker></example>
</rule>
<rule>
<pattern>
<token postag='ARTPRE-M:s'></token>
<token postag='NOUN-M:p'></token>
</pattern>
<message>La preposizione articolata non concorda con il sostantivo che la segue</message>
<example type="correct">Il libro <marker>dell'amico amici</marker>.</example>
<example type="incorrect">Il libro <marker>dello amici</marker></example>
</rule>
<rule>
<rule>
<pattern>
<token postag='ARTPRE-F:p'></token>
<token postag='NOUN-F:s'></token>
</pattern>
<message>La preposizione articolata non concorda con il sostantivo che la segue</message>
<example type="correct">Il libro <marker>dell'amica</marker>.</example>
<example type="incorrect">Il libro <marker>delle amica</marker></example>
</rule>
<rule>
<pattern>
<token postag='ARTPRE-F:s'></token>
<token postag='NOUN-F:p'></token>
</pattern>
<message>La preposizione articolata non concorda con il sostantivo che la segue</message>
<example type="correct">Il libro <marker>dell'amica</marker>.</example>
<example type="incorrect">Il libro <marker>della amiche</marker></example>
</rule>
</rulegroup>
In the rules above, I am getting a few false positives. Most of them relate to foreign words, which are unchanged in their singular and plural forms. For instance, according to the anlysis, “cinema” is both NOUN-M:s and NOUN-M:p in Italian. Can you suggest a procedure that will allow the rule to ignore nouns that are identical in their singular and plural forms?
thank you very much for your suggestion. I am still not familiar with the exception command, but I have added it to my rules and they now seem to work. I am pasting the whole rule below. Note that Microsoft WordĘĽs grammar check offers this rule as standard, so I think it makes sense to add it to LanguageTool:
<rulegroup id="ConcordanzaPreposizioneArticolata-Sostantivo" name="Concordanza preposizione articolata - sostantivo">
<rule>
<pattern>
<token postag='ARTPRE-M:p'></token>
<token postag='NOUN-M:s'><exception postag="NOUN-M:p"/></token>
</pattern>
<message>La preposizione articolata non concorda con il sostantivo che la segue</message>
<example type="correct">Il libro <marker>degli amici</marker>.</example>
<example type="incorrect">Il libro <marker>degli amico</marker></example>
</rule>
<rule>
<pattern>
<token postag='ARTPRE-M:s'></token>
<token postag='NOUN-M:p'><exception postag="NOUN-M:s"/></token>
</pattern>
<message>La preposizione articolata non concorda con il sostantivo che la segue</message>
<example type="correct">Il libro <marker>dell'amico amici</marker>.</example>
<example type="incorrect">Il libro <marker>dello amici</marker></example>
</rule>
<rule>
<rule>
<pattern>
<token postag='ARTPRE-F:p'></token>
<token postag='NOUN-F:s'><exception postag="NOUN-F:p"/></token>
</pattern>
<message>La preposizione articolata non concorda con il sostantivo che la segue</message>
<example type="correct">Il libro <marker>dell'amica</marker>.</example>
<example type="incorrect">Il libro <marker>delle amica</marker></example>
</rule>
<rule>
<pattern>
<token postag='ARTPRE-F:s'></token>
<token postag='NOUN-F:p'><exception postag="NOUN-F:s"/></token>
</pattern>
<message>La preposizione articolata non concorda con il sostantivo che la segue</message>
<example type="correct">Il libro <marker>dell'amica</marker>.</example>
<example type="incorrect">Il libro <marker>della amiche</marker></example>
</rule>
</rulegroup>
Hi Roberto, thanks for the rules. I have added them to the “Grammatica - Preposizioni” category, please let me know if that doesn’t make sense. They will become available on languagetool.org later today at around 22:15 CEST.