LanguagueTool规则中的标点符号

时间:2016-05-27 14:21:04

标签: regex xml spell-checking languagetool

我无法想象我们如何编写令牌包含单词和标点符号组合的规则。

我应该如何处理LanguageTool规则中的标点符号?

我在网上看过并试过几件事无济于事。

例如,1)

<rule id="THAT_AND_THAN_DOT" name="that and than dot">
<pattern>
<token>that</token> 
<token regexp="yes"> 
another.|
himself.|
herself.|
itself.</token>
</pattern>
<message>Did you mean <suggestion>than \2.</suggestion>?</message>
<example correction='than another.'>Yes, better <marker>than another. </marker></example>
</rule> 

2)

<rule id="THAT_AND_THAN_DOT" name="that and than dot">
<pattern>
<token>that</token> 
<token regexp="yes"> 
another|
himself|
herself|
itself</token>
<token regexp="yes">
[.]</token> 
</pattern>
<message>Did you mean <suggestion>than \2.</suggestion>?</message>
<example correction='than another.'>Yes, better <marker>than another. </marker></example>
</rule>

和3)

<rule id="THAT_AND_THAN_DOT" name="that and than dot">
<pattern>
<token>that</token> 
<token regexp="yes"> 
another|
himself|
herself|
itself</token>
<token regexp="yes">
[:punct:]</token> 
</pattern>
<message>Did you mean <suggestion>than \2.</suggestion>?</message>
<example correction='than another.'>Yes, better <marker>than another. </marker></example>
</rule>

失败。另一方面

<rule id="THAT_AND_THAN_DOT" name="that and than dot">
    <pattern>
    <token>that</token> 
    <token regexp="yes"> 
    another|
    himself|
    herself|
    itself</token>
    </pattern>
    <message>Did you mean <suggestion>than \2.</suggestion>?</message>
    <example correction='than another.'>Yes, better <marker>than another. </marker></example>
    </rule>

虽然没有考虑到我想做的点,但仍有效。

注意:我在LanguageTool内使用Texstudio

1 个答案:

答案 0 :(得分:1)

你的代码2)几乎可以工作,只是你的模式中有一个标记that但是你的例句中有than,所以它永远不会匹配,与标点符号无关。通常,标点符号会获得自己的标记,因此它也需要在模式中拥有自己的标记。您可以使用http://community.languagetool.org/ruleEditor/expert测试规则,如果出现问题,它还会显示带有应用标记的消息。