提取主语、谓语、宾语等词功能的软件
software to extract word functions like subject, predicate, object etc
我需要提取句子中单词的关系。我最感兴趣的是识别主语、谓语和宾语。例如,对于下面的句子:
She gave him a pen
我想要:
She_subject gave_predicate him a pen_object.
斯坦福NLP能做到吗?我已经尝试了他们的 relation
注释器,但它似乎没有像我预期的那样工作?也许还有其他软件可以产生这种结果?
根据http://nlp.stanford.edu/software/lex-parser.shtml, Stanford NLP does have a parser which can identify the subject and predicate of a sentence. You can try it out online http://nlp.stanford.edu:8080/parser/index.jsp。您可以使用类型化的依赖关系来识别主语、谓语和宾语。
在示例页面中,句子 My dog also likes eating sausage 将为您提供以下解析:
(ROOT
(S
(NP (PRP$ My) (NN dog))
(ADVP (RB also))
(VP (VBZ likes)
(S
(VP (VBG eating)
(NP (NN sausage)))))
(. .)))
解析器还可以生成依赖:
poss(dog-2, My-1)
nsubj(likes-4, dog-2)
advmod(likes-4, also-3)
root(ROOT-0, likes-4)
xcomp(likes-4, eating-5)
dobj(eating-5, sausage-6)
依存关系 nsubj
显示主要谓语和主语——在本例中,likes 和 dog。数字给出了单词在句子中的位置(出于某种原因,单索引)。 dobj
依赖表示谓词和宾语的关系。 xcomp
依赖关系提供有关谓词的内部信息。
当谓词不是动词时,这也适用:我的狗很大而且负责 给出:
poss(dog-2, My-1)
nsubj(large-4, dog-2)
cop(large-4, is-3)
root(ROOT-0, large-4)
cc(large-4, and-5)
conj(large-4, in-6)
pobj(in-6, charge-7)
这告诉我们large
是主谓词(nsubj(large-4, dog-2)
),但是有一个系词(cop(large-4, is-3)
),还有一个连词和一个带宾语的介词.
我不熟悉API,所以我不能给出确切的代码。也许其他知道 API 的人可以做到这一点。解析器记录在 the Stanford NLP doc site. You might also find the answer to Tools for text simplification (Java) helpful. There's more information about the dependency format in The Stanford Dependency Manual。
Stanford 解析器可以做到 :) 不过您需要查看依赖解析器。看看这个页面的底部:http://nlp.stanford.edu/software/lex-parser.shtml:
subject: nsubj(snapped, rain),
or direct object: dobj(shut, hub))
...
或查看此页面(斯坦福依存关系):
http://nlp.stanford.edu/software/stanford-dependencies.shtml
要了解注释,请查看以下内容:
http://nlp.stanford.edu/software/dependencies_manual.pdf
我更喜欢在这种情况下使用 spaCy,使用 spaCy 位移的可视化如下:
你可以在他们的官方网站上轻松访问:
在那里你可以弄清楚主题词将具有 "nsubj" 或 "normal subject" 的依存关系,而谓语是具有依存关系的词 "root" 这意味着不依赖于其他单词。
我需要提取句子中单词的关系。我最感兴趣的是识别主语、谓语和宾语。例如,对于下面的句子:
She gave him a pen
我想要:
She_subject gave_predicate him a pen_object.
斯坦福NLP能做到吗?我已经尝试了他们的 relation
注释器,但它似乎没有像我预期的那样工作?也许还有其他软件可以产生这种结果?
根据http://nlp.stanford.edu/software/lex-parser.shtml, Stanford NLP does have a parser which can identify the subject and predicate of a sentence. You can try it out online http://nlp.stanford.edu:8080/parser/index.jsp。您可以使用类型化的依赖关系来识别主语、谓语和宾语。
在示例页面中,句子 My dog also likes eating sausage 将为您提供以下解析:
(ROOT
(S
(NP (PRP$ My) (NN dog))
(ADVP (RB also))
(VP (VBZ likes)
(S
(VP (VBG eating)
(NP (NN sausage)))))
(. .)))
解析器还可以生成依赖:
poss(dog-2, My-1)
nsubj(likes-4, dog-2)
advmod(likes-4, also-3)
root(ROOT-0, likes-4)
xcomp(likes-4, eating-5)
dobj(eating-5, sausage-6)
依存关系 nsubj
显示主要谓语和主语——在本例中,likes 和 dog。数字给出了单词在句子中的位置(出于某种原因,单索引)。 dobj
依赖表示谓词和宾语的关系。 xcomp
依赖关系提供有关谓词的内部信息。
当谓词不是动词时,这也适用:我的狗很大而且负责 给出:
poss(dog-2, My-1)
nsubj(large-4, dog-2)
cop(large-4, is-3)
root(ROOT-0, large-4)
cc(large-4, and-5)
conj(large-4, in-6)
pobj(in-6, charge-7)
这告诉我们large
是主谓词(nsubj(large-4, dog-2)
),但是有一个系词(cop(large-4, is-3)
),还有一个连词和一个带宾语的介词.
我不熟悉API,所以我不能给出确切的代码。也许其他知道 API 的人可以做到这一点。解析器记录在 the Stanford NLP doc site. You might also find the answer to Tools for text simplification (Java) helpful. There's more information about the dependency format in The Stanford Dependency Manual。
Stanford 解析器可以做到 :) 不过您需要查看依赖解析器。看看这个页面的底部:http://nlp.stanford.edu/software/lex-parser.shtml:
subject: nsubj(snapped, rain),
or direct object: dobj(shut, hub))
...
或查看此页面(斯坦福依存关系): http://nlp.stanford.edu/software/stanford-dependencies.shtml
要了解注释,请查看以下内容: http://nlp.stanford.edu/software/dependencies_manual.pdf
我更喜欢在这种情况下使用 spaCy,使用 spaCy 位移的可视化如下:
你可以在他们的官方网站上轻松访问:
在那里你可以弄清楚主题词将具有 "nsubj" 或 "normal subject" 的依存关系,而谓语是具有依存关系的词 "root" 这意味着不依赖于其他单词。