altafrahman / clearnlp

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

NPE in DEPNode.toString(List<DEPArc> heads) #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. parse a sentence 'The train leaves at 5pm.' using 
EngineProcess.getDEPTree(...)
2. print the resultant DEPTree
3. experience the NPE

What is the expected output? What do you see instead?
1   The the DT  _   2   det     _   _
2   train   train   NN  _   3   nsubj       3:A0    _
3   leaves  leave   VBZ pb=leave.XX 0   root        _   _
4   at  at  IN  _   3   prep        3:AM-TMP    _
5   5   0   CD  _   6   num     _   _
6   pm  pm  NN  _   4   pobj        _   _
7   .   .   .   _   3   punct       _   _

Null pointer stacktrace

What version of the product are you using? On what operating system?
1.2.1

Please provide any additional information below.

add a null check before Collections.sort(...)

    private String toString(List<DEPArc> heads)
    {
        StringBuilder build = new StringBuilder();

        Collections.sort(heads);

        for (DEPArc arc : heads)
        {
            build.append(DEPLib.DELIM_HEADS);
            build.append(arc.toString());
        }

        if (build.length() > 0)
            return build.substring(DEPLib.DELIM_HEADS.length());
        else
            return AbstractColumnReader.BLANK_COLUMN;
    }

Original issue reported on code.google.com by cmba...@gmail.com on 9 Nov 2012 at 11:08

GoogleCodeExporter commented 8 years ago
Patched (all of 2 lines) in my clone:
https://code.google.com/r/admackin-clearnlp-spans/source/detail?r=cf32641bd538be
cacd863f9e9d2b6ac5949c799f

Original comment by admac...@gmail.com on 8 Feb 2013 at 5:46