1

トークンに単語と句読点の組み合わせが含まれるルールの書き方がわかりません。

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ます。

4

1 に答える 1

1

2) のコードはほとんど機能しますがthat、パターンにはトークンが含まれていthanますが、例文にはトークンがあるため、句読点に関係なく一致することはありません。一般に、句読点は独自のトークンを取得するため、パターン内にも独自のトークンが必要です。http://community.languagetool.org/ruleEditor/expertでルールをテストできます。問題が発生した場合は、トークン化が適用されたメッセージも表示されます。

于 2016-05-27T16:03:52.390 に答える