待挖掘关键字列表:
keywords_list = ['object-oriented programming','information security industry','python','java programmer']这是一个文本,上面的关键字必须挖掘出来:
text = "***Python*** allows programmers to define their own types using classes and also ***python*** are most often used for ***object-oriented programming*** .***Python*** has also seen extensive use in the ***information security industry***, including in exploit development."从上面的文本中,我们必须挖掘给定的关键字,这些关键字可能在文本中,也可能不在文本中。此外,我们还必须计算文本中存在的关键字数量。
输出:
mined_words = ['python','object-oriented programming','information security industry']
count = [3,1,1]发布于 2017-07-23 19:22:02
count_list = [text.lower().count(kw) for kw in keywords_list]
mined_text = dict(zip(keywords_list, count_list))
output = sorted(mined_text, key = mined_text.get, reverse=True)
count_output = [mined_text.get(out) for out in output]在未来,最好发布你的进度并寻求建议。现在,希望这对你有用。
https://stackoverflow.com/questions/45261803
复制相似问题