本文整理汇总了Python中nltk.stem.wordnet.WordNetLemmatizer.title方法的典型用法代码示例。如果您正苦于以下问题:Python WordNetLemmatizer.title方法的具体用法?Python WordNetLemmatizer.title怎么用?Python WordNetLemmatizer.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.stem.wordnet.WordNetLemmatizer
的用法示例。
在下文中一共展示了WordNetLemmatizer.title方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: filter_inferred
# 需要导入模块: from nltk.stem.wordnet import WordNetLemmatizer [as 别名]
# 或者: from nltk.stem.wordnet.WordNetLemmatizer import title [as 别名]
def filter_inferred(self, result_vec, candidates, pos):
filtered_results = {}
candidates_found = set()
if result_vec != None:
for word, weight in result_vec:
wn_pos = to_wordnet_pos[pos]
lemma = WordNetLemmatizer().lemmatize(word, wn_pos)
if lemma in candidates:
self.add_inference_result(lemma, weight, filtered_results, candidates_found)
if lemma.title() in candidates:
self.add_inference_result(lemma.title(), weight, filtered_results, candidates_found)
if word in candidates: # there are some few cases where the candidates are not lemmatized
self.add_inference_result(word, weight, filtered_results, candidates_found)
if word.title() in candidates: # there are some few cases where the candidates are not lemmatized
self.add_inference_result(word.title(), weight, filtered_results, candidates_found)
# assign negative weights for candidates with no score
# they will appear last sorted according to their unigram count
# candidates_left = candidates - candidates_found
# for candidate in candidates_left:
# count = self.w2counts[candidate] if candidate in self.w2counts else 1
# score = -1 - (1.0/count) # between (-1,-2]
# filtered_results[candidate] = score
return filtered_results