0

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

这是代码:

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);

这是输出:

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>

如您所见,处理因错误而中止,请您帮我修复错误

4

1 回答 1

0

您正在调用的函数的 HeidelTime

String result = H.process(textFile,resultFormatter );

在其文档评论中说:

/**
 * 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 {

如果你想用 NEWS 调用它,那么你也必须指定一个时间,作为文档和结果格式化程序之间的额外参数。

于 2016-05-01T16:26:23.963 回答