gpt4 book ai didi

java - 如果我想使用单个 UIMA 依赖库,是否需要重写整个 java 项目?

转载 作者:行者123 更新时间:2023-11-30 04:20:04 24 4
gpt4 key购买 nike

我想使用https://code.google.com/p/heideltime/在一个java项目中。该代码“适合 UIMA 管道”,这是我根本不理解的。 UIMA 看起来是为了解决大量我没有的问题而设计的,所以我只想获得运行该代码所需的最少量的 UIMA。

是否有一个简单的示例来说明如何运行简单的 UIMA 程序?

我已经添加

    <dependency>
<groupId>org.uimafit</groupId>
<artifactId>uimafit</artifactId>
<version>1.4.0</version>
</dependency>

<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>uimaj-core</artifactId>
<version>2.4.0</version>
</dependency>

<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>uimaj-tools</artifactId>
<version>2.4.0</version>
</dependency>

到我的pom.xml,但由于某种原因maven仍然不会编译这个:

import org.apache.uima.jcas.JCas;
import org.apache.uima.util.Level;
import org.uimafit.component.JCasAnnotator_ImplBase;
import org.uimafit.descriptor.ConfigurationParameter;
import org.uimafit.descriptor.TypeCapability;
import org.uimafit.examples.tutorial.type.RoomNumber;

public class RoomNumberAnnotatorPipeline {

public static void main(String[] args) throws Exception {
String text = "The meeting was moved from Yorktown 01-144 to Hawthorne 1S-W33.";
TypeSystemDescription tsd = createTypeSystemDescription( "org.uimafit.examples.tutorial.type.RoomNumber");
JCas jCas = createJCas(tsd);
// jCas.setDocumentText(text);
// AnalysisEngine analysisEngine = createPrimitive(RoomNumberAnnotator.class, tsd);
// analysisEngine.process(jCas);
//
// for (RoomNumber roomNumber : select(jCas, RoomNumber.class)) {
// System.out.println(roomNumber.getCoveredText() + "\tbuilding = "
// + roomNumber.getBuilding());
// }
}
}


[ERROR] symbol : class TypeSystemDescription
[ERROR] location: class com.stackoverflow.RoomNumberAnnotatorPipeline

enter image description here

UIMA 依赖项是否比典型的 Java 库更重要?仅从 Maven Central 提取 UIMA 并开始在我现有的代码中使用它们的类还不够吗?

好吧,我以某种方式让这个例子工作了(我不知道它是什么,并且仍然困惑为什么它之前不起作用)我仍然无法使用 heideltime:

package org.ryan;

import static org.uimafit.factory.AnalysisEngineFactory.createPrimitive;
import static org.uimafit.factory.JCasFactory.createJCas;
import static org.uimafit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription;
import static org.uimafit.util.JCasUtil.select;

import org.apache.uima.UIMAException;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.uimafit.examples.tutorial.ex1.RoomNumberAnnotator;
import org.uimafit.examples.tutorial.type.RoomNumber;


/**
* Hello world!
*
*/
public class UIMAWTF
{
public static void main( String[] args ) throws UIMAException
{
String text = "The meeting was moved from Yorktown 01-144 to Hawthorne 1S-W33. Today is May 5, 2013.";

TypeSystemDescription tsd = createTypeSystemDescription("org.uimafit.examples.tutorial.type.RoomNumber");
JCas jCas = createJCas(tsd);

jCas.setDocumentText(text);
AnalysisEngine analysisEngine = createPrimitive(RoomNumberAnnotator.class, tsd);
analysisEngine.process(jCas);

for (RoomNumber roomNumber : select(jCas, RoomNumber.class)) {
System.out.println(roomNumber.getCoveredText() + "\tbuilding = "
+ roomNumber.getBuilding());
}

}
}

编辑现在正在尝试:

HeidelTimeStandalone hts_sci = new HeidelTimeStandalone(Language.ENGLISH, DocumentType.NEWS, OutputType.TIMEML);//, configPath);
dates = hts_sci.process("19-Nov-2013", new Date(2012,01,05), new TimeMLResultFormatter());

System.out.println(dates);

获取:

Jul 3, 2013 2:02:41 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone initialize
INFO: HeidelTimeStandalone initialized with language english
Jul 3, 2013 2:02:41 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone readConfigFile
INFO: trying to read in file config.props
java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:61)
at java.io.InputStreamReader.<init>(InputStreamReader.java:55)
at de.unihd.dbs.uima.annotator.heideltime.resources.GenericResourceManager.readResourcesFromDirectory(GenericResourceManager.java:45)
at de.unihd.dbs.uima.annotator.heideltime.resources.NormalizationManager.<init>(NormalizationManager.java:58)
at de.unihd.dbs.uima.annotator.heideltime.resources.NormalizationManager.getInstance(NormalizationManager.java:73)
at de.unihd.dbs.uima.annotator.heideltime.HeidelTime.initialize(HeidelTime.java:143)
at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.initialize(HeidelTimeStandalone.java:153)
at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.<init>(HeidelTimeStandalone.java:128)
at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.<init>(HeidelTimeStandalone.java:112)
at com.hrl.issl.osi.date.LocalHeidelTime.main(LocalHeidelTime.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:662)
Jul 3, 2013 2:02:41 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone initialize
WARNING: HeidelTime could not be initialized
java.lang.NullPointerException
at org.apache.uima.util.XMLInputSource.<init>(XMLInputSource.java:118)
at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.initialize(HeidelTimeStandalone.java:163)
at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.<init>(HeidelTimeStandalone.java:128)
at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.<init>(HeidelTimeStandalone.java:112)
at com.hrl.issl.osi.date.LocalHeidelTime.main(LocalHeidelTime.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:662)
Jul 3, 2013 2:02:41 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone initialize
WARNING: JCas factory could not be initialized

最佳答案

上面写着HeidelTime's homepage

HeidelTime is available as UIMA annotator and as standalone version.

我有一个独立版本 here 。你应该能够破解de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.java主要是为了满足您的需求。

关于java - 如果我想使用单个 UIMA 依赖库,是否需要重写整个 java 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17283557/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com