在ruta中的两个带注释的标签之间获取文本

问题描述 投票:0回答:1

如何在两个带注释的文本之间显示数据?

样本输入:

Seller Name  FirstAvenue Mortgage, TN 12230     Contact Name John

代码:

BLOCK(sellerName) Line{CONTAINS(SellerNameKeyword)} {
    c:ANY+{-PARTOF(SellerNameKeyword), -PARTOF(SellerName)-> 
        CREATE(SellerName, "label"="Seller Name", "value"=c.ct)} 
ContactNameKeyword;
    }

此代码未提供SellerName annotation的任何输出

预期输出:FirstAvenue Mortgage, TN 12230

如果输入分布在两行中会发生什么变化?

样本输入:

Seller Name  FirstAvenue Mortgage, Contact Name John   
             TN 12230              Contact Title Supervisor

上述用例代码:

TYPESYSTEM utils.PlainTextTypeSystem;
ENGINE utils.PlainTextAnnotator;

DECLARE Keyword (STRING label);
DECLARE Entry(Keyword keyword);

DECLARE Keyword SellerNameKeyword, SellerNameContextBlocker, ContactNameKeyword;

EXEC(PlainTextAnnotator, {Line,Paragraph});

ADDRETAINTYPE(WS);
Line{->TRIM(WS)};
Paragraph{->TRIM(WS)}; 
REMOVERETAINTYPE(WS);

"Seller Name" -> SellerNameKeyword ( "label" = "Seller Name");
"Contact Title" -> SellerNameContextBlocker("label" = "Seller Name Context Blocker");
"Contact Name" -> ContactNameKeyword("label"= "Contact Name");

DECLARE Entity (STRING label, STRING value);
DECLARE Entity ContactName, SellerName;

BLOCK(line1) Line{CONTAINS(ContactNameKeyword)} {
    ContactNameKeyword c:#{-PARTOF(ContactName)-> CREATE(ContactName,"label"="Contact Name", "value"=c.ct)};
}
SellerNameKeyword c:#{-PARTOF(ContactNameKeyword),-PARTOF(SellerNameContextBlocker),-PARTOF(ContactName) -> 
    CREATE(SellerName,"label"="Seller Name", "value"=c.ct)} SellerNameContextBlocker;

输出:FirstAvenue Mortgage, Contact Name John TN 12230

预期输出:FirstAvenue Mortgage, TN 12230

请提出必要的更改以及我错过的内容?

uima ruta
1个回答
0
投票

由于您要注释的信息在文本中不是连续的(介于“ Contact Name John”之间,因此您无法在CAS中将所需的输出表示为单个注释的覆盖文本。但是,根据您的情况,您可能希望将感兴趣的文本连接到输出注释的功能中。例如:

DECLARE SellerNameKeyword, ContactNameKeyword, ContactTitleKeyword;
DECLARE SellerName (STRING  value);

"Seller Name" -> SellerNameKeyword;
"Contact Name" -> ContactNameKeyword;
"Contact Title" -> ContactTitleKeyword;

ADDRETAINTYPE(BREAK);
SellerNameKeyword ANY[0,5]{-PARTOF(ContactNameKeyword), -PARTOF(COMMA) -> 
s1:CREATE(SellerName)} COMMA? 
ContactNameKeyword ANY[0,5]{-PARTOF(BREAK)} BREAK? ANY[0,10]{-PARTOF(ContactTitleKeyword) -> 
s2:CREATE(NameId), s1.value=""+s1.ct+s2.ct} ContactTitleKeyword;
ADDRETAINTYPE(BREAK);

此规则的输出将在“ FirstAvenue Mortgage”上返回带有特征SellerName的注释value,其中包含所需的输出“ FirstAvenue Mortgage TN 12230”。

请注意,这不是一般的解决方案,而是一个在给定情况下如何完成的示例。

© www.soinside.com 2019 - 2024. All rights reserved.