SNOWNLP Text sentiment analysis using

Source: Internet
Author: User

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:


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.marshal ') #保存模型 from
SNOWNLP import tag
Tag.train (' 199801.txt ') (' Tag.marshal ') from
snownlp import sentiment
sentiment.train (' Neg.txt ', ' pos.txt ') (' Sentiment.marshal ')
For the principle of word segmentation, the principle of POS tagging, the specific space github:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.