how to use heideltime tool in java code

672 views Asked by At

i want to use heideltime tool in my java code, so i downloaded heideltime-standalone,and i imported de.unihd.dbs.heideltime.standalone.jar as well as stanford-postagger.jar.

here is the code :

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

and here is the output:

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>

as you can see the Processing aborted due to errors, would you please help me to fix the errors

1

There are 1 answers

0
Rup On

The HeidelTime that function you're calling

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

says in its doc comment:

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

If you want to call this with NEWS then you'll have to specify a time too, as an extra parameter between the document and result formatter.