问题描述
我想自动识别文档流中的日期,从这个意义上讲,我想使用开源项目Heideltime提供的代码,该代码可在此处().我已经安装了Heideltime套件(不是独立版本),现在我想知道如何在Java项目中引用它并对其进行调用.我已经在pom.xml的Heideltime中添加了一个依赖项:
I would like to automatically identify dates inside a stream of documents and in this sense I would like to use the code provided by the open source project Heideltime, available here (https://code.google.com/p/heideltime/). I have installed the Heideltime kit (not the standalone version) and now I am wondering how can I reference it and call it inside my Java project. I have already added a dependecy to Heideltime inside my pom.xml:
<dependency>
<groupId>de.unihd.dbs</groupId>
<artifactId>heideltime</artifactId>
<version>1.7</version>
</dependency>
但是我不确定如何从源项目中调用类到我自己的项目中.我都使用Maven.以前使用过它的任何人都可以给我建议或建议吗?非常感谢!
however I am not sure how to call the classes from this source project into my own project. I am using Maven for both. Anyone who has used it before could maybe give me a suggestion or piece of advice? Many thanks!
推荐答案
heideltime-kit本身是一个Maven项目.因此,您可以将heideltime-kit项目添加为依赖项. (在Netbeans中,右键单击Dependencies,-> Add Dependency-> Open Projects(确保首先打开该项目)-> HeidelTime)
heideltime-kit is itself a Maven project. So, you can add the heideltime-kit project as a dependency. (In Netbeans, right click on Dependencies, --> Add Dependency --> Open Projects (make sure the project is open first) --> HeidelTime)
然后将config.props文件移动到项目的src/main/resources文件夹中.在config.props中将路径设置为treetagger.
Then move the config.props file into your project's src/main/resources folder. Set the path to treetagger within config.props.
就使用这些类而言,您将需要使用POSTagger.TREETAGGER作为posTagger参数和到的硬编码路径来创建HeidelTimeStandalone实例(请参阅de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.java).您的src/main/resources/config.props文件作为configPath参数.例如,
As far as using the classes goes, you'll want to create an instance of HeidelTimeStandalone (see de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.java) using POSTagger.TREETAGGER as the posTagger parameter and a hardcoded path to your src/main/resources/config.props file as the configPath parameter.For example,
heidelTime = new HeidelTimeStandalone(Language.ENGLISH,
DocumentType.COLLOQUIAL,
OutputType.TIMEML,
"path/to/config.props",
POSTagger.TREETAGGER, true);
然后使用HeidelTime处理文本,您可以简单地调用处理函数:
Then to use HeidelTime to process text, you can simply call the process function:
String result = heidelTime.process(text, date);
这篇关于如何在Java项目中使用HeidelTime时间标记器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!