【问题标题】:Training Stanford POS tagger for unstructured sentences为非结构化句子训练斯坦福 POS 标注器
【发布时间】:2018-02-06 11:35:22
【问题描述】:

对于像“x 代表苹果”或“x 和 y 代表苹果和香蕉”这样的句子,我希望 POS 标记器适当地标记单词,就像句子“Java 代表咖啡豆”一样。或者有没有其他更好的解析器可以为这些非结构化句子提供 POS 标记。

我还需要在我尝试使用斯坦福解析器的句子中找到依赖关系,如果有人知道更好的方法,请提出建议。 我正在 python 中尝试所有这些东西。

【问题讨论】:

    标签: python stanford-nlp pos-tagger


    【解决方案1】:

    我使用 SpaCy。 https://spacy.io/

    它被设计为开箱即用的 NLP 管道,因此您无需更改模型的任何内容。它给出了给定句子的“通用”和“Penn 树库”POS 标签。

    它也做依赖标记。

    【讨论】:

      【解决方案2】:

      你可以试试这个

      >>> import nltk
      >>> import re
      >>> from nltk.tokenize import word_tokenize
      >>> from nltk.tag import pos_tag
      >>> sentence = 'x and y represents apples and bananas'
      >>> sentence1 = nltk.word_tokenize(sentence)
      >>> sentence1 = nltk.pos_tag(sentence1)
      >>> grammar = "NP: {<DT>?<JJ>*<NN>}"
      >>> cp = nltk.RegexpParser(grammar)
      >>> result = cp.parse(sentence1)
      >>> print(result)
      (S
        (NP x/NN)
        and/CC
        y/JJ
        represents/VBZ
        apples/NNS
        and/CC
        bananas/NNS)
      >>> result.draw()
      

      或者

      您可以查看a sentence POS and dependency tree.的更多详细信息

      【讨论】:

      • 这个语句应该被解析为“Ram 和 Sita 分别喜欢芒果和苹果”。但是这里 x 和 y 没有被归类为名词,所以这是本任务的挑战。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多