如何运行uima-text-segmenter的例子?

时间:2014-04-01 04:01:46

标签: uima text-segmentation

我想调用uima-text-segmenter https://code.google.com/p/uima-text-segmenter/source/browse/trunk/INSTALL?r=22的API来运行一个例子。 但我不知道如何调用API ... 自述文件说,

With the DocumentAnalyzer, run the following descriptor
`desc/textSegmenter/wst-snowball-C99-JTextTilingAAE.xml` by taking the 
uima-examples data as input.

有人能给我一些可以直接在main func中运行的代码吗? 非常感谢!

1 个答案:

答案 0 :(得分:1)

答案很长:

该链接描述了如何在Eclipse UIMA环境中设置应用程序。这种设置通常针对主题专家,几乎没有编码经验。它允许它们以声明的方式与UIMA一起工作(相对快速):所有数据结构和分析引擎(UIMA中的计算块)都在xml中声明(在其上面有一个GUI),之后框架负责处理休息。在这种情况下,您通常使用Eclipse中的运行配置(或包含的UIMA管道运行程序应用程序)运行UIMA管道。幸运的是,UIMA允许您从代码中完全相同,但我建议使用UIMAFit(http://uima.apache.org/d/uimafit-current/tools.uimafit.book.html#d5e137)来代替UIMA,因为它捆绑了许多有用的东西和编码快捷方式。

简短回答:

使用UIMAFit,您可以从(第三方提供的)XML文件中调用Factory方法来创建CollectionReader(读取输入),AnalysisEngine(进程输入)和Consumer对象(写入/执行其他操作)。使用这些方法构造管道和SimplePipeline类来运行它。要提取所需的数据,您可以在Consumer对象中操作CAS对象(包含数据),可能还有回调。您也可以在Analysis Engine对象中执行此操作。我建议使用DKPro的FeaturePathFactory(https://code.google.com/p/dkpro-core-asl/source/browse/de.tudarmstadt.ukp.dkpro.core-asl/trunk/de.tudarmstadt.ukp.dkpro.core.api.featurepath-asl/src/main/java/de/tudarmstadt/ukp/dkpro/core/api/featurepath/FeaturePathFactory.java?spec=svn1811&r=1811)快速访问您所使用的功能。

代码示例:

http://uima.apache.org/d/uimafit-current/tools.uimafit.book.html#d5e137包含示例,但它们都是相反的方向(类对象用于工厂方法,而不是XML文件 - 从这些类生成XML)。查看UIMAFit API以查找所需的方法,例如XML中的AnalysisEngineDescription:http://uima.apache.org/d/uimafit-current/api/org/apache/uima/fit/factory/AnalysisEngineFactory.html#createEngineDescriptionFromPath-java.lang.String-java.lang.Object...-