【问题标题】:Search for an item in a text file using UIMA Ruta使用 UIMA Ruta 在文本文件中搜索项目
【发布时间】:2016-02-16 11:23:14
【问题描述】:

我一直在尝试搜索文本文件中的项目。

文本文件就像 例如:`

>标题

00345

XYZ

方法名:fdsafk

日期:23-4-2012

更多文本和一些包含 XYZ 实例的部分

所以我最初在字典中搜索了 XYZ 并找到了位置,但我只想要第一个 XYZ 而不是其余的。 XYZ 有一个属性,它总是在 5 位代码和文本 MethondName 之间。

我无法做到这一点。

WORDLIST ZipList = 'Zipcode.txt';
DECLARE Zip;
Document
Document{-> MARKFAST(Zip, ZipList)};

DECLARE Method;
"MethodName" -> Method;


WORDLIST typelist = 'typelist.txt';
DECLARE type;
Document{-> MARKFAST(type, typelist)};

另外,我们如何在 UIMA RUTA 中使用 REGEX?

【问题讨论】:

    标签: regex annotations nlp uima ruta


    【解决方案1】:

    有很多方法可以指定这一点。以下是一些示例(未经测试):

    // just remove the other annotations (assuming type is the one you want)
    type{-> UNMARK(type)} ANY{-STARTSWITH(Method)};
    
    // only keep the first one: remove any annotation if there is one somewhere in front of it
    // you can also specify this with POSISTION or CURRENTCOUNT, but both are slow
    type # @type{-> UNMARK(type)}
    
    // just create a new annotation in between
    NUM{REGEXP(".....")} #{-> type} @Method;
    

    在 UIMA Ruta 中有两个使用正则表达式的选项:

    • (查找)简单的正则表达式规则,例如"[A-Za-z]+" -> Type;
    • (匹配)用于验证规则元素匹配的 REGEXP 条件,例如
      ANY{REGEXP("[A-Za-z]+")-> Type};

    如果有什么不清楚的地方请告诉我。那我就扩展一下描述吧。

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

    【讨论】:

    • 嘿彼得,感谢您的帮助。真的很有帮助。我还有一个疑问。是否可以选择将输出导出或导出为 CSV 或 XLS。如果有,您能否提供相同的代码。
    • UIMA Ruta 不提供这样的组件。我通常为此任务编写自定义分析引擎或 cas 使用者,因为布局通常是特定于项目的。最好在 UIMA 用户列表上提问或在此处创建新问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    相关资源
    最近更新 更多