首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LanguageTool :单词后面的单词与

LanguageTool :单词后面的单词与
EN

Stack Overflow用户
提问于 2016-06-03 18:11:04
回答 2查看 105关注 0票数 0

如何匹配一系列单词与x不同的单词

例如,如何匹配at the cost of后面的单词与some不同

我尝试了以下几点,但都没有结果:

代码语言:javascript
复制
<rule id="AT_THE_COST_OF_!SOME" name="at the cost of !some">
<pattern>
<token>at</token>
<token>the</token>
<token>cost</token>
<token>of</token>
<token regexp="yes">/^((?!some).)*$</token>
</pattern>
<message>Did you mean <suggestion>at the cost of some \5</suggestion>?</message>
<example correction='at the cost of some efforts'>Yes, it comes 
<marker>at the cost of efforts</marker>.</example>
</rule>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-06-04 15:35:54

LanguageTool在令牌上工作。使用regexp是一种特例,如果使用regexp,则使用单个标记(当使用pattern时)。这将解决您的问题:

代码语言:javascript
复制
<pattern>
    <token>at</token>
    <token>the</token>
    <token>cost</token>
    <token>of</token>
    <token><exception>some</exception></token>
</pattern>

无论如何,要使用正则表达式,请使用<regexp>,如http://wiki.languagetool.org/development-overview#toc8中所记录的那样。

票数 0
EN

Stack Overflow用户

发布于 2016-06-03 18:39:12

传统的正则表达式也可以使用<regexp>标记而不是<token>标记。(但需要LanguageTool 3.2或更高版本才能使用<regexp>)。想了解更多信息- 维基

<regexp>(at the cost of (?!some\b))\w+<regexp>

匹配的模式:

以某人为代价 不惜一切代价

丢弃的模式:

付出一些代价

请测试一下这里

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37620964

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档