首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在java代码中使用heideltime工具

如何在java代码中使用heideltime工具
EN

Stack Overflow用户
提问于 2016-05-02 00:15:05
回答 1查看 610关注 0票数 0

我想在java代码中使用heideltime工具,所以我下载了heideltime-standalone,并导入了de.unihd.dbs.heideltime.standalone.jar和stanford-postagger.jar。

代码如下:

代码语言:javascript
复制
String textFile ="مدى اسبوع";
HeidelTimeStandalone H = new HeidelTimeStandalone(Language.ARABIC,
                DocumentType.NEWS,
                OutputType.TIMEML,
                "/heideltime-standalone/config.props",
                POSTagger.STANFORDPOSTAGGER,true);
        String result = H.process(textFile,resultFormatter );
        System.out.print(result);

下面是输出:

代码语言:javascript
复制
mai 01, 2016 5:09:54 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone initialize
INFOS: HeidelTimeStandalone initialized with language arabic
mai 01, 2016 5:09:54 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone readConfigFile
INFOS: trying to read in file /heideltime-standalone/config.props
May 01, 2016 5:09:56 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone initialize
INFO: HeidelTime initialized
May 01, 2016 5:09:56 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone initialize
INFO: JCas factory initialized
May 01, 2016 5:09:56 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone process
INFO: Processing started
de.unihd.dbs.heideltime.standalone.exceptions.DocumentCreationTimeMissingException
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.provideDocumentCreationTime(HeidelTimeStandalone.java:304)
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.process(HeidelTimeStandalone.java:493)
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.process(HeidelTimeStandalone.java:427)
    at Arabic_Parser.main(Arabic_Parser.java:54)
May 01, 2016 5:09:56 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone process
WARNING: Processing aborted due to errors
May 01, 2016 5:09:56 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone process
INFO: Result formatted
<?xml version="1.0"?>
<!DOCTYPE TimeML SYSTEM "TimeML.dtd">
<TimeML>
مدى اسبوع
</TimeML>

由于您可以看到由于错误而中止的处理,您可以帮助我修复这些错误吗

EN

回答 1

Stack Overflow用户

发布于 2016-05-02 00:26:24

要调用函数的HeidelTime

代码语言:javascript
复制
String result = H.process(textFile,resultFormatter );

in its doc comment

代码语言:javascript
复制
/**
 * Processes document with HeidelTime
 * 
 * @param document
 * @return Annotated document
 * @throws DocumentCreationTimeMissingException
 *             If document creation time is missing when processing a
 *             document of type {@link DocumentType#NEWS}. Use
 *             {@link #process(String, Date)} instead to provide document
 *             creation time!
 */
public String process(String document, ResultFormatter resultFormatter)
        throws DocumentCreationTimeMissingException {
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36968862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档