UIMA RUTA - 如何模拟 IF-ELSE-Condition?

UIMA RUTA - How to simulate a IF-ELSE-Condition?

I am currently trying to solve the following use-case in RUTA:

If a Fragment contains one or more words from a WordlistA, then CREATE(Process, "finished" = "true")
If the Fragment contains none of the words from the WordlistA, then CREATE(Process, "finished" = "false")

So the created annotation Process@finished should be either true or false but never 'true' and 'false' at the same time.

I tried this one:

DECLARE Process (STRING finsihed);
WORDLIST WordlistA = 'mywordlist.txt';
Document{-> MARKFAST(ProcessTerm, WordlistA)};
Fragment {} -> {ProcessTerm {-> CREATE(Process, "finished" = "true")};};
Fragment {-CONTAINS(ProcessTerm) -> CREATE(Process, "finished" = "false")};

As far as I can see, the second rule matches always!?但为什么? As a result the ProcessTerm@finished annotation contains 'true' and 'false' if the first rule matches, too.

What is the best way to achive the use-case using RUTA? In my opinion, I need something like an IF-ELSE-Statement.

As the use case changed a little bit in the last two hours into

If a **Document** contains one or more words from a WordlistA, then CREATE(Process, "finished" = "true")
If the **Document** contains none of the words from the WordlistA, then CREATE(Process, "finished" = "false")

I am now using Peters proposal in the following way:

Document->{
  Document{CONTAINS(ProcessTerm)-> CREATE(Process, "finished" = "true")};
  Document{-PARTOF(Process) -> CREATE(Process, "finished" = "false")};
};

Ruta 中没有 IF-THEN 结构(目前)。最相似的是两个具有互斥条件的 BLOCK 结构。嗯,这也可以通过规则来实现。

遵守您的规则: 如果第二条规则始终匹配,则每个 Fragment 注释中没有(可见的)ProcessTerm 注释。

在您的第一条规则中,您为每个 Fragment 注释中的每个 ProcessTerm 注释创建 Process 注释。

如果我没有误解你的描述,我认为这可能就是你要找的东西:

Fragment {CONTAINS(ProcessTerm) -> CREATE(Process, "finished" = "true")};
Fragment {-CONTAINS(ProcessTerm) -> CREATE(Process, "finished" = "false")};

这将遍历所有 Fragment 注释两次,这并不是真正必要的。你也可以做类似的事情(或任何带有 BLOCK 和变量的变体):

Fragment->{
  Document{CONTAINS(ProcessTerm)-> CREATE(Process, "finished" = "true")};
  Document{-PARTOF(Process) -> CREATE(Process, "finished" = "false")};
};

免责声明:我是 UIMA Ruta 的开发者