提取最频繁的名词和形容词使用nltk来描述这些名词

时间:2016-01-10 14:42:21

标签: python nltk

我想用NLTK找到最常用的名词和从文本中描述这些名词的形容词,然后找到那些名词的同义词。然后我想集中这些文件。

import nltk

from nltk.tag import *

sentence = """Michale Scofield is an engineer. He is expert in java. He knows coding very well.
He think world is like a big system of computers.A big system of computer involves the servers, servers are nothing but super-fast machines"""

tagged_sent = pos_tag(sentence.split())
print(tagged_sent)

nouns = [word for word,pos in tagged_sent if pos == 'NNP' or pos=='NN']

print(nouns)

freq_nouns=nltk.FreqDist(nouns)

freq_nouns.most_common(3)

我曾尝试但无法得到名词和描述那些名词的形容词,它应该是最常用的名词。

对于上面的句子我想要输出

  专家java,   大系统,   超快速机器

有人可以帮助我。

0 个答案:

没有答案