Skip to content

silverguo/unisense

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unisense

a homemade python package for sentiment analysis

installation

python setup.py install

requirement

  • scikit-learn

usage

from unisense.en import EnLogRegSentiment

a toy model is provided in ./unisense/test/en/model/

# create sentiment class
test = EnLogRegSentiment(model_path='./toy_model.pkl')

return the sentiment score, input should be list of string

# text analysis
test.analysis(['Hello world!'])

for each document, the score is tuple of neg and pos probability

example

rule based sentiment model for english

from unisense.en import EnRuleSentiment
model = EnRuleSentiment()
vocab = {'hello': -1, 'word': -1, 
         'hello world': -1, 'world hello': -1}
model.train(vocab)
model.create_matcher()
model.kw_match(['hello World word'])

exception

  • model not exist
  • vocab format error
  • input format error

test

pytest --pyargs unisense

doc

  • en
    • EnLogRegSentiment
    • EnRuleSentiment
  • fr
    • FrRuleSentiment

Generally, the sentiment class has the following functions

  • train()
  • load_model()
  • save_model()
  • analysis()

to be done

About

python package for sentiment analysis

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages