我能用Uima Ruta分割一个单词的字母吗?
例如。
1.(WHO)
2.(APIAs)剧本:
DECLARE NEW;
BLOCK (foreach)CAP{}
{
W{REGEXP(".")->MARK(NEW)};
}发布于 2016-08-05 13:36:54
是的,这是用UIMA中的简单正则表达式规则实现的:
DECLARE Char;
CAP->{"."->Char;};您不能为此使用常规规则,因为您需要匹配比RutaBasic更小的东西。唯一的选择是使用regexp规则,它直接对文本进行操作,而不是对注释进行操作。当然,您应该非常小心,因为这会导致很多注释。
对稍微紧凑的规则的一些解释:CAP->{"."->Char;};
CAP // the only rule element of the rule: match on each CAP annotation
->{// indicates that inlined rules follow that are applied in the context of the matched annotation.
"." // a regular expression matching on each character
-> Char // the "action" of the regex rule: create an annotation of the type Char for each match of the regex
;}; // end of regex rule, end of inlined rules, end of actual rule总之,该规则遍历所有CAP注释,对每个迭代覆盖的文本应用正则表达式,并为匹配创建注释。
当然,您也可以使用块而不是内联规则。
免责声明:我是UIMA Ruta的开发人员
https://stackoverflow.com/questions/38722273
复制相似问题