【问题标题】:Customize the pos_tag of a word in spacyspacy中自定义一个单词的pos_tag
【发布时间】:2018-08-13 05:15:02
【问题描述】:

我正在使用 spacy 来处理语句中单词的 pos_tags,我希望将单词 select 读取为 动词在所有情况下。所以,“我想选择一件棕色衬衫”和“选择棕色衬衫”(不管语法如何)都应该有选择作为动词。

有没有办法在 spacy(python) 中做到这一点?

【问题讨论】:

    标签: python spacy pos-tagger


    【解决方案1】:

    一种可能的解决方案是编写自己的函数来获取词性,如果出现“选择”一词,它将覆盖 spaCy 的函数。 大致如下:

    def get_pos(tok):
        return tok.tag_ if (str(tok) != "select") \
               else "VB" # <- Return whatever POS tag you'd like. 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-28
      • 2018-09-14
      • 1970-01-01
      • 2020-04-18
      • 2019-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多