NLP - 识别哪个形容词描述句子中的哪个名词

时间:2017-03-11 23:04:51

标签: nlp text-mining data-science

我需要一种方法/算法来识别哪个形容词与句子中的哪个名词有关。

示例输入:

"The product itself is good however this company has a terrible service"

作为输出,我想得到类似的东西:

[product, good]
[service, terrible]

你能指点一些有助于完成这项任务的算法/库吗?

1 个答案:

答案 0 :(得分:5)

您可以使用Stanford dependency parser,也可以使用此relevant paper。您也可以查看他们的在线工具。例如,对于您的句子,您可以从斯坦福解析器中获取以下内容。

您的查询

The product itself is good however this company has a terrible service.

标记

The/DT product/NN itself/PRP is/VBZ good/JJ however/RB this/DT company/NN has/VBZ a/DT terrible/JJ service/NN ./.

解析

(ROOT
  (S
    (NP (DT The) (NN product))
    (ADVP (PRP itself))
    (VP (VBZ is)
      (ADJP (JJ good))
      (SBAR
        (WHADVP (RB however))
        (S
          (NP (DT this) (NN company))
          (VP (VBZ has)
            (NP (DT a) (JJ terrible) (NN service))))))
    (. .)))

普遍依赖

det(product-2, The-1)
nsubj(good-5, product-2)
advmod(good-5, itself-3)
cop(good-5, is-4)
root(ROOT-0, good-5)
advmod(has-9, however-6)
det(company-8, this-7)
nsubj(has-9, company-8)
dep(good-5, has-9)
det(service-12, a-10)
amod(service-12, terrible-11)
dobj(has-9, service-12)