SNOWNLP is a python version of the text Analysis tool, Ubuntu install SNOWNLP command: Pip install SNOWNLP.
The use of SNOWNLP can be used for word segmentation, pos tagging, Text digest extraction, text sentiment analysis, the following posted SNOWNLP participle, part-of-speech tagging, sentiment analysis code as follows:
From SNOWNLP import SNOWNLP
s = snownlp (U ' This thing is really great ')
key=s.words # [u ' this ', U ' something ', U ' true ',
# u ' very ', U ' likes ']
PO S=s.tags # [(U ' This ', U ' r '), (U ' Something ', U ' n '), # (U ' true ', U ' d '), (U '
very ', U ' d '),
# (U ' like ', U ' Vg ')]
sentiment=s.sentime Nts
Sentiment analysis simply divides the sentences into two categories, positive and negative, that is, the probability that the input sentence is positive and negative, sentiment belongs to [0,1]. At the same time, we can use our own training data training model, Python participle, part-of-speech tagging, affective analysis training code as follows:
From SNOWNLP import seg
seg.train (' data.txt ')
seg.save (' Seg.marshal ') #保存模型 from
SNOWNLP import tag
Tag.train (' 199801.txt ')
tag.save (' Tag.marshal ') from
snownlp import sentiment
sentiment.train (' Neg.txt ', ' pos.txt ')
sentiment.save (' Sentiment.marshal ')
For the principle of word segmentation, the principle of POS tagging, the specific space github:https://github.com/isnowfy/snownlp