我目前使用spacy遍历依赖树,并生成实体.
nlp = get_spacy_model(detect_lang(unicode_text))
doc = nlp(unicode_text)
entities = set()
for sentence in doc.sents:
# traverse tree picking up entities
for token in sentence.subtree:
## pick entitites using some pre-defined rules
entities.discard('')
return entities
Spacy有什么好的Java替代品吗?
我正在寻找生成依赖树的库,就像Spacy所做的那样.
编辑:
我查看了Stanford Parser
但是,它生成了以下解析树:
ROOT
|
NP
_______________|_________
| NP
| _________|___
| | PP
| | ________|___
NP NP | NP
____|__________ | | _______|____
DT JJ JJ NN NNS IN DT JJ NN
| | | | | | | | |
the quick brown fox jumps over the lazy dog
但是,我期待像Spacy这样的树结构:
jumps_VBZ
__________________________|___________________
| | | | | over_IN
| | | | | |
| | | | | dog_NN
| | | | | _______|_______
The_DT quick_JJ brown_JJ fox_NN ._. the_DT lazy_JJ
最佳答案 你正在寻找
Stanford Dependency Parser.像大多数斯坦福工具一样,这也是在depparse注释器下与
Stanford CoreNLP捆绑在一起的.其他解析器包括
Malt parser(基于特征的移位缩减解析器)和Ryan McDonald的
MST parser(准确但较慢的最大生成树解析器).