用户:JimmyBoy查看:0 回复:0 评论:0 创建时间:2020-05-11T16:06:40
from snownlp import SnowNLP,summary
from pyecharts import Line
import webbrowser
import os
with open ("滚滚长江东逝水.txt","r",encoding="utf-8-sig") as a:
text = a.readlines()
print(text)
sen_score = {}
sentiment = []
poem = []
for i in text:
a1 = SnowNLP(i)
a2 = a1.sentiments
# print(i,a2)
sentiment.append(a2)
poem.append(i)
sen_score[a2] = i
print(sen_score)
print(poem)
print(sentiment)
b = sorted(sentiment)
print(b)
s=" ".join(text)
print(s)
t = SnowNLP(s)
print("中心句",t.summary(2))
line = Line("滚滚长江东逝水","明状元-杨慎")
line.add("Jimmy所著,诗词之美",poem , sentiment,is_label_show=False,mark_point=["max","min"])
line.render()
webbrowser.open("file://"+os.path.realpath("render.html"))
这是我编写的解析
【腾讯文档】snownlp 中文
https://docs.qq.com/doc/DZWJab1BWS3RRa1dR
有问题可以喵qq 1969765920.备注[bcmlt6528].