当前位置: 首页>>代码示例>>Python>>正文


Python WordNetLemmatizer.lower方法代码示例

本文整理汇总了Python中nltk.stem.wordnet.WordNetLemmatizer.lower方法的典型用法代码示例。如果您正苦于以下问题:Python WordNetLemmatizer.lower方法的具体用法?Python WordNetLemmatizer.lower怎么用?Python WordNetLemmatizer.lower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nltk.stem.wordnet.WordNetLemmatizer的用法示例。


在下文中一共展示了WordNetLemmatizer.lower方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: countexp_noun

# 需要导入模块: from nltk.stem.wordnet import WordNetLemmatizer [as 别名]
# 或者: from nltk.stem.wordnet.WordNetLemmatizer import lower [as 别名]
def countexp_noun(para, searchText):
    cnt = 0
    searchWords = [WordNetLemmatizer().lemmatize(s.lower(), 'n') for s in searchText]
    for stxt in searchWords:
        for word in para.split():
            w1 = WordNetLemmatizer().lemmatize(word.lower(), 'n')
            if stxt.lower() == w1.lower():
                cnt = cnt + 1
                break
    return cnt
开发者ID:Sahana14,项目名称:QuestionAnswering,代码行数:12,代码来源:Keywordcount.py

示例2: extractSubjectObject

# 需要导入模块: from nltk.stem.wordnet import WordNetLemmatizer [as 别名]
# 或者: from nltk.stem.wordnet.WordNetLemmatizer import lower [as 别名]
  def extractSubjectObject(self, sentence):

    sub = None
    obj = None

    for word in sentence:
      if sub == None and word[7] == "nsubj":
        sub = word[2].translate(string.maketrans("",""), string.punctuation)
        sub = sub.lower()
        sub = WordNetLemmatizer().lemmatize(sub, pos="n")
      if obj == None and word[7] == "dobj":
        obj = word[2].translate(string.maketrans("",""), string.punctuation)
        obj = obj.lower()
        obj = WordNetLemmatizer().lemmatize(obj, pos="n")

    # The sentence did not contain a verb, so we need to back-off to
    # using the tokens tagged with NN (word[4]). Brute-force take the first
    # two tokens tagged with NN.
    #
    # Example use : A big cow in a field. -> cow, field.
    if sub == None:
      for word in sentence:
        if word[4] == "NN":
          sub = word[2].translate(string.maketrans("",""), string.punctuation)
          sub = sub.lower()
          sub = WordNetLemmatizer().lemmatize(sub, pos="n")
          break

    if obj == None:
      for word in sentence:
        if word[4] == "NN":
          proposal = word[2].translate(string.maketrans("",""), string.punctuation)
          proposal = proposal.lower()
          proposal = WordNetLemmatizer().lemmatize(proposal, pos="n")
          if proposal != sub:
            obj = proposal
            break

    return sub, obj
开发者ID:elliottd,项目名称:vdrparser,代码行数:41,代码来源:SemiSupervisedVDR.py


注:本文中的nltk.stem.wordnet.WordNetLemmatizer.lower方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。