from gradio_interfaces import ifaceif __name__ =="__main__":iface.launch()
lib_word_cloud.py
from wordcloud import WordCloud, ImageColorGenerator
import numpy as np
from PIL import Imagefrom consts import*deftext2wordcount_normal(text:str,background_color:str="white",margin =2,min_font_size =4,max_font_size =200,font_path =None,width:int=400,height:int=200,):ifnot background_color or""==str(background_color).strip():background_color ="white"ifnot min_font_size or min_font_size <1:min_font_size =4ifnot max_font_size or max_font_size <4:max_font_size =200ifnot font_path or""==str(font_path).strip():font_path = DEFAULT_FONT_PATHifnot width or width <1:width =400ifnot height or height <1:height =200# Generate a word cloud imagewordcloud = WordCloud(font_path=font_path,width=width, height=height, background_color=background_color, max_words=2000, margin=margin, min_font_size=min_font_size, max_font_size=max_font_size, random_state=42).generate(text)return wordcloud.to_image()deftext2wordcount_mask(text:str,background_color:str="white",margin =2,min_font_size =4,max_font_size =200,font_path =None,mask_image =None,mask_color =None,contour_width=3,contour_color="steelblue",):ifnot background_color or""==str(background_color).strip():background_color ="white"ifnot min_font_size or min_font_size <1:min_font_size =4ifnot max_font_size or max_font_size <4:max_font_size =200ifnot font_path or""==str(font_path).strip():font_path = DEFAULT_FONT_PATHifnot contour_width or contour_width <0:contour_width =3ifnot contour_color or""==str(contour_color).strip():contour_color ="steelblue"# mask_colorif mask_color isnotNone:image_colors = ImageColorGenerator(mask_color,True)else:image_colors = ImageColorGenerator(mask_image,True)# Generate a word cloud imagewordcloud = WordCloud(font_path=font_path,mask=mask_image,background_color=background_color,color_func=image_colors,contour_width=contour_width,contour_color=contour_color,max_words=2000, margin=margin, min_font_size=min_font_size, max_font_size=max_font_size, random_state=42).generate(text)return wordcloud.to_image()
jieba_util.py
import jieba
# jieba.enable_parallel(4)from consts import*# The function for processing text with Jiebadefjieba_processing_txt(text, userdict_list=['阿Q','孔乙己','单四嫂子']):if userdict_list isnotNone:for word in userdict_list:jieba.add_word(word)mywordlist =[]seg_list = jieba.cut(text, cut_all=False)liststr ="/ ".join(seg_list)withopen(STOPWORDS_PATH, encoding='utf-8')as f_stop:f_stop_text = f_stop.read()f_stop_seg_list = f_stop_text.splitlines()for myword in liststr.split('/'):ifnot(myword.strip()in f_stop_seg_list)andlen(myword.strip())>1:mywordlist.append(myword)return' '.join(mywordlist)
CleanMyMac X 4.15.3破解版是一款专业的Mac系统清理软件,可一键智能扫描清理mac系统日志缓存磁盘垃圾和多余语言安装包,快速释放电脑内存,轻松管理和升级Mac上的应用。同时CleanMyMac X 破解版可以强力卸载恶意软件,修复系统漏洞&…