Stanford Java NLP选区标签缩写

问题描述 投票:0回答:1

使用斯坦福Java CoreNLP库,我有这个:

            String text = "My name is Anthony";
            CoreDocument doc = new CoreDocument(text);
            pipeline.annotate(doc);
            for(Tree t : doc.sentences().get(0).constituencyParse()) {
                String tmp = "";
                for(Word w : t.yieldWords()) {
                    tmp = tmp + " " + w.word();
                }
                System.out.println(t.label().toString() + " - " + WordParts.getValue(t.label().toString()) + " - " + tmp);

现在,程序输出此:

ROOT - INVALID -  My name is Anthony
S - INVALID -  My name is Anthony
NP - INVALID -  My name
PRP$ - Possessive pronoun -  My
My-1 - INVALID -  My
NN - Singular noun -  name
name-2 - INVALID -  name
VP - INVALID -  is Anthony
VBZ - 3rd person singular present verb -  is
Subject:  Anthony
is-3 - INVALID -  is
NP - INVALID -  Anthony
NNP - Proper singular noun -  Anthony
Anthony-4 - INVALID -  Anthony

WordParts.java的缩写来自此帖子(Java Stanford NLP: Part of Speech labels?),可以在这里找到类文件:(https://github.com/AJ4real/References/blob/master/WordParts.java)我知道标签不是Parts of Speech,因为某些值返回INVALID,那么如何找到t.label().toString()缩写的完整术语呢?

java nlp stanford-nlp
1个回答
0
投票

[其余为Penn Treebank短语类别。例如,请参见此处:

https://gist.github.com/nlothian/9240750

© www.soinside.com 2019 - 2024. All rights reserved.