有人能指出我正确的方向来解决以下问题吗? 我从UMLS医学术语巨人名单,即一个样本可能是 Disease control is good
Disease control is poor
Disease control is excellent
Drug adherence
Current drug
Sodium Valproate
Antibiotic VI
Epilepsy con
我在我的代码,这个错误,我不知道如何固定 import nltk
from nltk.util import ngrams
def word_grams(words, min=1, max=4):
s = []
for n in range(min, max):
for ngram in ngrams(words, n):
s.append('
比方说,我有这样的文字: 'he is hdajs asdas da he is not asd as da s i am a da daas you am a'
我已经创建了所有从这个文本的二元语法: >>> bigrams_
[('he', 'is'), ('is', 'hdajs'), ('hdajs', 'asdas'), ('asdas', 'da'), ('da', 'he'),
从文档中我想生成包含某个单词的所有n元组。 例子: document: i am 50 years old, my son is 20 years old
word: years
n: 2
输出: [(50, years), (years, old), (20, years), (years, old)]
我知道我们可以生成所有可能的正克并过滤掉字的那些,但我不知道是否有更有效的方法来