aschaeffer / heideltime

Automatically exported from code.google.com/p/heideltime
0 stars 0 forks source link

NullPointerException in TreeTaggerWrapper #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Simple test using the TreeTaggerWrapper (the environment is well configured 
with the resources from here: 
http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/):

import java.util.Calendar;
import java.util.Date;

import de.unihd.dbs.heideltime.standalone.DocumentType;
import de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone;
import de.unihd.dbs.heideltime.standalone.OutputType;
import de.unihd.dbs.heideltime.standalone.POSTagger;
import de.unihd.dbs.heideltime.standalone.components.impl.TimeMLResultFormatter;
import 
de.unihd.dbs.heideltime.standalone.exceptions.DocumentCreationTimeMissingExcepti
on;
import de.unihd.dbs.uima.annotator.heideltime.resources.Language;

public class HeidelTest {

    public static void main(String[] args)
        throws DocumentCreationTimeMissingException {

    final String configProps = "/config.props";

    String configPath = HeidelTest.class.getResource(configProps).getFile();

    HeidelTimeStandalone heidel = new HeidelTimeStandalone(Language.FRENCH,
        DocumentType.NEWS, OutputType.TIMEML, configPath,
        POSTagger.TREETAGGER);

    Date documentCreationTime = Calendar.getInstance().getTime();

    String result = heidel.process(
"samedi 13 décembre 2014 à 20h00.",
        documentCreationTime, new TimeMLResultFormatter());

    System.out.println(result);
    }

}

2.
3.

What is the expected output? What do you see instead?

java.lang.NullPointerException
    at de.unihd.dbs.uima.annotator.treetagger.TreeTaggerWrapper.doTreeTag(TreeTaggerWrapper.java:494)
    at de.unihd.dbs.uima.annotator.treetagger.TreeTaggerWrapper.process(TreeTaggerWrapper.java:227)
    at de.unihd.dbs.heideltime.standalone.components.impl.TreeTaggerWrapper.process(TreeTaggerWrapper.java:43)
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.establishPartOfSpeechInformation(HeidelTimeStandalone.java:388)
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.establishHeidelTimePreconditions(HeidelTimeStandalone.java:336)
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.process(HeidelTimeStandalone.java:481)
    at com.glue.feed.html.demo.dates.HeidelTest.main(HeidelTest.java:37)

What version of the product are you using? On what operating system?
HeidelTime 1.8 on Ubuntu 64

Please provide any additional information below.

Looking at the code in de.unihd.dbs.uima.annotator.treetagger.TreeTaggerWrapper 
class, line 494:

 if ((!(token.getPos().equals(null))) &&
         (token.getPos().equals("EMPTYLINE"))){
         token.removeFromIndexes();
         }

token.getPos() cannot be compared to null by calling the equals method on it if 
it is actually null...

So, the previous portion of code should be replaced by:

if (token.getPos() != null
            && token.getPos().equals("EMPTYLINE")) {
            token.removeFromIndexes();
        }

Original issue reported on code.google.com by pascalgi...@gmail.com on 14 Dec 2014 at 10:24

GoogleCodeExporter commented 9 years ago
Hi and thanks for the report.

We actually fixed that exact issue in that exact way back in September (see 
re16ec31522e9) and the code is part of the 1.8 release. Can you check whether 
your setup has an older version of HeidelTime in its CLASSPATH?

I've tested your code and it works perfectly for me without modification in an 
Eclipse project that has HeidelTime's 1.8 standalone .jar set as a library:

14.12.2014 13:18:20 de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone 
initialize
INFO: HeidelTimeStandalone initialized with language french
14.12.2014 13:18:20 de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone 
readConfigFile
INFO: trying to read in file /home/julian/workspace/test123/bin/config.props
14.12.2014 13:18:20 de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone 
initialize
INFO: HeidelTime initialized
14.12.2014 13:18:21 de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone 
initialize
INFO: JCas factory initialized
14.12.2014 13:18:21 de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone 
process
INFO: Processing started
14.12.2014 13:18:21 de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone 
process
INFO: Processing finished
<?xml version="1.0"?>
<!DOCTYPE TimeML SYSTEM "TimeML.dtd">
<TimeML>
<TIMEX3 tid="t2" type="DATE" value="2014-12-13">samedi 13 décembre 
2014</TIMEX3> à <TIMEX3 tid="t10" type="TIME" 
value="2014-12-13T20:00">20h00</TIMEX3>.
</TimeML>
14.12.2014 13:18:21 de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone 
process
INFO: Result formatted

Original comment by z...@informatik.uni-heidelberg.de on 14 Dec 2014 at 12:24

GoogleCodeExporter commented 9 years ago
Ooohh, my mistake: I had the 1.7 release. Yet I downloaded it a few days ago 
only from https://code.google.com/p/heideltime/wiki/Downloads ... Maybe I 
clicked on the links for the old releases.

Sorry for the loss of time.

Original comment by pascalgi...@gmail.com on 14 Dec 2014 at 12:55

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
We released 1.8 on Monday and I think that's when we last edited that page, 
too. I guess the download buttons could be more prominent, but we don't get a 
lot to work with in terms of Wiki markup...

No worries. 

Original comment by z...@informatik.uni-heidelberg.de on 14 Dec 2014 at 1:05

GoogleCodeExporter commented 9 years ago
That's why ! :D

2014-12-14 14:04 GMT+01:00 <heideltime@googlecode.com>:

Original comment by pascalgi...@gmail.com on 14 Dec 2014 at 1:08

GoogleCodeExporter commented 9 years ago
If i'm not mistaken, the version in the pom.xml is still 1.7.

Pascal

2014-12-14 14:07 GMT+01:00 Pascal Gillet <pascalgill3t@gmail.com>:

Original comment by pascalgi...@gmail.com on 14 Dec 2014 at 1:23

GoogleCodeExporter commented 9 years ago
You're absolutely right. I'll have to repackage the kit.

Original comment by z...@informatik.uni-heidelberg.de on 14 Dec 2014 at 1:28