def __get_model_answer(self, question):
tag1 = jieba.analyse.extract_tags(question, 3)
tag2 = jieba.analyse.textrank(question, 3)
keywords = []
for tag in tag1:
keywords.append(tag)
for tag in tag2:
if tag not in tag1:
keywords.append(tag)
tr4w = TextRank4Keyword()
tr4w.analyze(text=question, lower=True, window=2)
for item in tr4w.get_keywords(20, word_min_len=1):
if item.word not in keywords:
keywords.append(item.word)
kstr = ""
for k in keywords:
if len(k) != 1:
kstr = kstr + "AND" + k
else:
if k not in kstr:
kstr = kstr + "AND" + k
# print(k)
estr = kstr[3:]
print (estr)
q = self.__parser.parse(estr)
results = self.__searcher.search(q)
return results
评论列表
文章目录