You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
840 B

from .utils import *
import json
import sys
sys.path.append('..')
from word_cloud import *
# def getCommentsImage(searchIpt):
# searchName = list(df.loc[df['title'].str.contains(searchIpt)]['title'])[0]
# comments = df[df['title'] == searchName]['comments'].values[0]
# comments = json.loads(comments)
# resSrc = getImageByComments(comments)
# return resSrc, searchName
def getCommentsImage(searchIpt):
searchResults = df.loc[df['title'].str.contains(searchIpt)]
if searchResults.empty:
return '', '' # 如果没有搜索结果,返回消息和 None
searchName = searchResults['title'].values[0]
comments = df[df['title'] == searchName]['comments'].values[0]
comments = json.loads(comments)
# print(comments)
resSrc = getImageByComments(comments)
return resSrc, searchName