
    Of	                     J    S r SSKJr  SSK7   " S S\5      r " S S\5      rg)	a
  
CorpusReader for the Opinion Lexicon.

Opinion Lexicon information
===========================

Authors: Minqing Hu and Bing Liu, 2004.
    Department of Computer Science
    University of Illinois at Chicago

Contact: Bing Liu, liub@cs.uic.edu
        https://www.cs.uic.edu/~liub

Distributed with permission.

Related papers:

- Minqing Hu and Bing Liu. "Mining and summarizing customer reviews".
    Proceedings of the ACM SIGKDD International Conference on Knowledge Discovery
    & Data Mining (KDD-04), Aug 22-25, 2004, Seattle, Washington, USA.

- Bing Liu, Minqing Hu and Junsheng Cheng. "Opinion Observer: Analyzing and
    Comparing Opinions on the Web". Proceedings of the 14th International World
    Wide Web conference (WWW-2005), May 10-14, 2005, Chiba, Japan.
    )WordListCorpusReader)*c                       \ rS rSrSrS rSrg)IgnoreReadmeCorpusView&   zI
This CorpusView is used to skip the initial readme block of the corpus.
c                     [         R                  " U /UQ70 UD6  U R                  5         [        U R                  5        U R                  R                  5       /U l        g N)StreamBackedCorpusView__init___openread_blankline_block_streamtell_filepos)selfargskwargss      D/usr/lib/python3/dist-packages/nltk/corpus/reader/opinion_lexicon.pyr   IgnoreReadmeCorpusView.__init__+   sF    ''>t>v>

T\\***,-    )r   N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes__ r   r   r   r   &   s    .r   r   c                   8    \ rS rSrSr\rS	S jrS rS r	S r
Srg)
OpinionLexiconCorpusReader5   ap  
Reader for Liu and Hu opinion lexicon.  Blank lines and readme are ignored.

    >>> from nltk.corpus import opinion_lexicon
    >>> opinion_lexicon.words()
    ['2-faced', '2-faces', 'abnormal', 'abolish', ...]

The OpinionLexiconCorpusReader provides shortcuts to retrieve positive/negative
words:

    >>> opinion_lexicon.negative()
    ['2-faced', '2-faces', 'abnormal', 'abolish', ...]

Note that words from `words()` method are sorted by file id, not alphabetically:

    >>> opinion_lexicon.words()[0:10] # doctest: +NORMALIZE_WHITESPACE
    ['2-faced', '2-faces', 'abnormal', 'abolish', 'abominable', 'abominably',
    'abominate', 'abomination', 'abort', 'aborted']
    >>> sorted(opinion_lexicon.words())[0:10] # doctest: +NORMALIZE_WHITESPACE
    ['2-faced', '2-faces', 'a+', 'abnormal', 'abolish', 'abominable', 'abominably',
    'abominate', 'abomination', 'abort']
Nc                     Uc  U R                   nO[        U[        5      (       a  U/n[        U R	                  USS5       VVVs/ s H   u  p#nU R                  X R                  US9PM"     snnn5      $ s  snnnf )a&  
Return all words in the opinion lexicon. Note that these words are not
sorted in alphabetical order.

:param fileids: a list or regexp specifying the ids of the files whose
    words have to be returned.
:return: the given file(s) as a list of words and punctuation symbols.
:rtype: list(str)
T)encoding)_fileids
isinstancestrconcatabspaths
CorpusView_read_word_block)r   fileidspathencfileids        r   words OpinionLexiconCorpusReader.wordsO   sz     ?mmG%%iG ,0==$+M+M'T &;&;cJ+M
 	
s   'A5c                 $    U R                  S5      $ )zh
Return all positive words in alphabetical order.

:return: a list of positive words.
:rtype: list(str)
zpositive-words.txtr.   r   s    r   positive#OpinionLexiconCorpusReader.positived        zz.//r   c                 $    U R                  S5      $ )zh
Return all negative words in alphabetical order.

:return: a list of negative words.
:rtype: list(str)
znegative-words.txtr1   r2   s    r   negative#OpinionLexiconCorpusReader.negativem   r5   r   c                     / n[        S5       H;  nUR                  5       nU(       d  M  UR                  UR                  5       5        M=     U$ )N   )rangereadlineappendstrip)r   streamr.   ilines        r   r)   +OpinionLexiconCorpusReader._read_word_blockv   s@    rA??$DLL&	 
 r   r   r	   )r   r   r   r   r   r   r(   r.   r3   r7   r)   r   r   r   r   r   r   5   s"    . (J
*00r   r   N)r   nltk.corpus.readerr   nltk.corpus.reader.apir
   r   r   r   r   r   <module>rE      s.   4 4 $.3 .H!5 Hr   