afinn, 在 python 中,AFINN情感分析

分享于 

4分钟阅读

GitHub

  繁體 雙語
AFINN sentiment analysis in Python
  • 源代码名称:afinn
  • 源代码网址:http://www.github.com/fnielsen/afinn
  • afinn源代码文档
  • afinn源代码下载
  • Git URL:
    git://www.github.com/fnielsen/afinn.git
    Git Clone代码到本地:
    git clone http://www.github.com/fnielsen/afinn
    Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/fnielsen/afinn
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
    afinn

    python 中的AFINN情感分析: 基于单词表的情感分析方法。

    示例

    
    
    
    
    >>> from afinn import Afinn
    
    
    >>> afinn = Afinn()
    
    
    >>> afinn.score('This is utterly excellent!')
    
    
    3.0
    
    
    
    

    在丹麦语中:

    
    
    
    
    >>> afinn = Afinn(language='da')
    
    
    >>> afinn.score('Hvis ikke det er det mest afskyelige flueknepperi...')
    
    
    -6.0
    
    
    
    

    在瑞典语中:

    
    
    
    
    >>> afinn = Afinn(language='sv')
    
    
    >>> afinn.score('det är inte bra')
    
    
    -2.0
    
    
    
    

    使用表情符:

    
    
    
    
    >>> afinn = Afinn(emoticons=True)
    
    
    >>> afinn.score('I saw that yesterday :)')
    
    
    2.0
    
    
    
    

    使用多个句子( 这里有来自Gutenberg的奥斯汀小说的数据):

    
    
    
    
    >>> from afinn import Afinn
    
    
    >>> from nltk.corpus import gutenberg
    
    
    >>> import textwrap
    
    
    >>> afinn = Afinn()
    
    
    >>> sentences = (" ".join(wordlist) for wordlist in gutenberg.sents('austen-sense.txt'))
    
    
    >>> scored_sentences = ((afinn.score(sent), sent) for sent in sentences)
    
    
    >>> sorted_sentences = sorted(scored_sentences)
    
    
    >>> print("n".join(textwrap.wrap(sorted_sentences[0][1], 70)))
    
    
    To attach myself to your sister, therefore, was not a thing to be
    
    
    thought of ;-- and with a meanness, selfishness, cruelty -- which no
    
    
    indignant, no contemptuous look, even of yours, Miss Dashwood, can
    
    
    ever reprobate too much -- I was acting in this manner, trying to
    
    
    engage her regard, without a thought of returning it. -- But one
    
    
    thing may be said for me : even in that horrid state of selfish vanity
    
    
    , I did not know the extent of the injury I meditated, because I did
    
    
    not THEN know what it was to love. 
    
    
    
    

    引用

    如果你作为一个科学家使用单词表或者代码,请引用下面的代码:

    • 微博客"。ESWC2011 workshop的过程'情感分析的单词列表评估 microposts making: 大的东西在小包里。 CEUR workshop 过程中的卷 718: 93: Milan,Milan,米兰 Stankovic,aba sah,Mariann,( 编辑)

    补充论文:http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/6006/pdf/imm6006.pdf

    请参见

    等。

    https://travis-ci.org/fnielsen/afinn.svg?branch=master

    https://coveralls.io/repos/fnielsen/afinn/badge.svg?branch=master:target:https://coveralls.io/github/fnielsen/afinn?branch=master

    Code issuesDownloadsOpen Hub