Module Expr Str ImportFrom alias Import alias ImportFrom alias ImportFrom alias Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign AttributeStore NameLoad attr NameLoad If CompareIs NameLoad NameLoad body Assign AttributeStore NameLoad attr ListLoad orelse Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assert Call NameLoad NameLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad For NameStore AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return ListComp AttributeLoad NameLoad attr comprehension NameStore AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Return Call AttributeLoad Str attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list decorator_list AttributeLoad NameLoad attr ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Assign AttributeStore NameLoad attr NameLoad If CompareIs NameLoad NameLoad body Assign AttributeStore NameLoad attr ListLoad orelse Assign AttributeStore NameLoad attr NameLoad If CompareIs NameLoad NameLoad body Assign AttributeStore NameLoad attr ListLoad orelse Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return Call AttributeLoad Str attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list decorator_list AttributeLoad NameLoad attr ClassDef bases NameLoad body Expr Str Assign NameStore NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults Call NameLoad Str body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr orelse If Call NameLoad NameLoad NameLoad body Assign NameStore ListLoad NameLoad Return Call NameLoad ListComp Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr keyword NameLoad comprehension TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr orelse If Call NameLoad NameLoad NameLoad body Assign NameStore ListLoad NameLoad Return Call NameLoad ListComp Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr comprehension NameStore NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad Call AttributeLoad NameLoad attr Str attr decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr Return Call NameLoad ListComp Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr keyword NameLoad comprehension TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Return Call NameLoad ListComp Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr keyword NameLoad comprehension TupleStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Return Call NameLoad ListComp Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr keyword NameLoad comprehension TupleStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore ListLoad For NameStore Call NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr If UnaryOpNot NameLoad body Return NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body While NameLoad body Assign NameStore Call AttributeLoad NameLoad attr If UnaryOpNot NameLoad body Return ListLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Assign NameStore Call NameLoad keyword Call AttributeLoad Call AttributeLoad NameLoad attr Num attr Break While NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr If UnaryOpNot NameLoad body Return ListLoad NameLoad If Call AttributeLoad NameLoad attr NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Return ListLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr SubscriptLoad NameLoad Index Num Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore ListLoad For NameStore Call AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr ListComp NameLoad comprehension NameStore Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore ListLoad For NameStore Call NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr SubscriptLoad NameLoad Index Num Return NameLoad decorator_list decorator_list
N/A N/A 
CorpusReader for reviews corpora (syntax based on Customer Review Corpus).

- Customer Review Corpus information -
Annotated by: Minqing Hu and Bing Liu, 2004.
    Department of Computer Sicence
    University of Illinois at Chicago

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

Distributed with permission.

The "product_reviews_1" and "product_reviews_2" datasets respectively contain
annotated customer reviews of 5 and 9 products from amazon.com.

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), 2004.

- Minqing Hu and Bing Liu. "Mining Opinion Features in Customer Reviews".
    Proceedings of Nineteeth National Conference on Artificial Intelligence
    (AAAI-2004), 2004.

- Xiaowen Ding, Bing Liu and Philip S. Yu. "A Holistic Lexicon-Based Appraoch to
    Opinion Mining." Proceedings of First ACM International Conference on Web
    Search and Data Mining (WSDM-2008), Feb 11-12, 2008, Stanford University,
    Stanford, California, USA.

Symbols used in the annotated reviews:

    [t] : the title of the review: Each [t] tag starts a review.
    xxxx[+|-n]: xxxx is a product feature.
    [+n]: Positive opinion, n is the opinion strength: 3 strongest, and 1 weakest.
          Note that the strength is quite subjective.
          You may want ignore it, but only considering + and -
    [-n]: Negative opinion
    ##  : start of each sentence. Each line is a sentence.
    [u] : feature not appeared in the sentence.
    [p] : feature not appeared in the sentence. Pronoun resolution is needed.
    [s] : suggestion or recommendation.
    [cc]: comparison with a competing product from a different brand.
    [cs]: comparison with a competing product from the same brand.

Note: Some of the files (e.g. "ipod.txt", "Canon PowerShot SD500.txt") do not
    provide separation between different reviews. This is due to the fact that
    the dataset was specifically designed for aspect/feature-based sentiment
    analysis, for which sentence-level annotation is sufficient. For document-
    level classification and analysis, this peculiarity should be taken into
    consideration.
 __future__ division N/A re nltk.corpus.reader.api * nltk.tokenize * N/A TITLE N/A N/A re compile ^\[t\](.*)$ N/A FEATURES N/A N/A re compile ((?:(?:\w+\s)+)?\w+)\[((?:\+|\-)\d)\] N/A NOTES N/A N/A re compile \[(?!t)(p|u|s|cc|cs)\] N/A SENT N/A N/A re compile ##(.*)$ Review N/A object N/A N/A 
    A Review is the main block of a ReviewsCorpusReader.
     __init__ N/A N/A self title review_lines N/A None None N/A N/A 
        :param title: the title of the review.
        :param review_lines: the list of the ReviewLines that belong to the Review.
         N/A N/A self title title N/A N/A review_lines None N/A N/A N/A self review_lines N/A N/A N/A N/A self review_lines review_lines N/A add_line N/A N/A self review_line N/A N/A N/A 
        Add a line (ReviewLine) to the review.

        :param review_line: a ReviewLine instance that belongs to the Review.
         N/A N/A isinstance review_line ReviewLine N/A N/A N/A N/A self review_lines append review_line N/A features N/A N/A self N/A N/A N/A 
        Return a list of features in the review. Each feature is a tuple made of
        the specific item feature and the opinion strength about that feature.

        :return: all features of the review as a list of tuples (feat, score).
        :rtype: list(tuple)
         N/A features N/A N/A review_line N/A self review_lines N/A N/A N/A N/A features extend N/A review_line features N/A features N/A sents N/A N/A self N/A N/A N/A 
        Return all tokenized sentences in the review.

        :return: all sentences of the review as lists of tokens.
        :rtype: list(list(str))
         N/A N/A N/A review_line sent N/A review_line N/A self review_lines N/A __repr__ N/A N/A self N/A N/A N/A N/A N/A Review(title="{}", review_lines={}) format N/A self title N/A self review_lines N/A N/A N/A compat python_2_unicode_compatible ReviewLine N/A object N/A N/A 
    A ReviewLine represents a sentence of the review, together with (optional)
    annotations of its features and notes about the reviewed item.
     __init__ N/A N/A self sent features notes N/A None None N/A N/A N/A self sent sent N/A N/A features None N/A N/A N/A self features N/A N/A N/A N/A self features features N/A N/A notes None N/A N/A N/A self notes N/A N/A N/A N/A self notes notes N/A __repr__ N/A N/A self N/A N/A N/A N/A N/A ReviewLine(features={}, notes={}, sent={}) format N/A self features N/A self notes N/A self sent N/A N/A N/A compat python_2_unicode_compatible ReviewsCorpusReader N/A CorpusReader N/A N/A 
    Reader for the Customer Review Data dataset by Hu, Liu (2004).
    Note: we are not applying any sentence tokenization at the moment, just word
    tokenization.

        >>> from nltk.corpus import product_reviews_1
        >>> camera_reviews = product_reviews_1.reviews('Canon_G3.txt')
        >>> review = camera_reviews[0]
        >>> review.sents()[0]
        ['i', 'recently', 'purchased', 'the', 'canon', 'powershot', 'g3', 'and', 'am',
        'extremely', 'satisfied', 'with', 'the', 'purchase', '.']
        >>> review.features()
        [('canon powershot g3', '+3'), ('use', '+2'), ('picture', '+2'),
        ('picture quality', '+1'), ('picture quality', '+1'), ('camera', '+2'),
        ('use', '+2'), ('feature', '+1'), ('picture quality', '+3'), ('use', '+1'),
        ('option', '+1')]

    We can also reach the same information directly from the stream:

        >>> product_reviews_1.features('Canon_G3.txt')
        [('canon powershot g3', '+3'), ('use', '+2'), ...]

    We can compute stats for specific product features:

        >>> from __future__ import division
        >>> n_reviews = len([(feat,score) for (feat,score) in product_reviews_1.features('Canon_G3.txt') if feat=='picture'])
        >>> tot = sum([int(score) for (feat,score) in product_reviews_1.features('Canon_G3.txt') if feat=='picture'])
        >>> # We use float for backward compatibility with division in Python2.7
        >>> mean = tot / n_reviews
        >>> print(n_reviews, tot, mean)
        15 24 1.6
     N/A CorpusView StreamBackedCorpusView __init__ N/A N/A self root fileids word_tokenizer encoding N/A N/A WordPunctTokenizer utf8 N/A N/A 
        :param root: The root directory for the corpus.
        :param fileids: a list or regexp specifying the fileids in the corpus.
        :param word_tokenizer: a tokenizer for breaking sentences or paragraphs
            into words. Default: `WordPunctTokenizer`
        :param encoding: the encoding that should be used to read the corpus.
         N/A N/A N/A CorpusReader __init__ self root fileids encoding N/A N/A self _word_tokenizer word_tokenizer N/A features N/A N/A self fileids N/A None N/A N/A 
        Return a list of features. Each feature is a tuple made of the specific
        item feature and the opinion strength about that feature.

        :param fileids: a list or regexp specifying the ids of the files whose
            features have to be returned.
        :return: all features for the item(s) in the given file(s).
        :rtype: list(tuple)
         N/A N/A fileids None N/A N/A fileids N/A self _fileids N/A N/A N/A isinstance fileids string_types N/A N/A fileids N/A fileids N/A N/A concat N/A N/A N/A self CorpusView fileid N/A self _read_features encoding enc N/A N/A fileid enc N/A N/A self abspaths fileids True N/A raw N/A N/A self fileids N/A None N/A N/A 
        :param fileids: a list or regexp specifying the fileids of the files that
            have to be returned as a raw string.
        :return: the given file(s) as a single string.
        :rtype: str
         N/A N/A fileids None N/A N/A fileids N/A self _fileids N/A N/A N/A isinstance fileids string_types N/A N/A fileids N/A fileids N/A N/A concat N/A N/A N/A N/A N/A self open f read N/A f fileids N/A readme N/A N/A self N/A N/A N/A 
        Return the contents of the corpus README.txt file.
         N/A N/A N/A N/A N/A self open README.txt read N/A reviews N/A N/A self fileids N/A None N/A N/A 
        Return all the reviews as a list of Review objects. If `fileids` is
        specified, return all the reviews from each of the specified files.

        :param fileids: a list or regexp specifying the ids of the files whose
            reviews have to be returned.
        :return: the given file(s) as a list of reviews.
         N/A N/A fileids None N/A N/A fileids N/A self _fileids N/A N/A concat N/A N/A N/A self CorpusView fileid N/A self _read_review_block encoding enc N/A N/A fileid enc N/A N/A self abspaths fileids True N/A sents N/A N/A self fileids N/A None N/A N/A 
        Return all sentences in the corpus or in the specified files.

        :param fileids: a list or regexp specifying the ids of the files whose
            sentences have to be returned.
        :return: the given file(s) as a list of sentences, each encoded as a
            list of word strings.
        :rtype: list(list(str))
         N/A N/A concat N/A N/A N/A self CorpusView path N/A self _read_sent_block encoding enc N/A N/A path enc fileid N/A N/A self abspaths fileids True True N/A words N/A N/A self fileids N/A None N/A N/A 
        Return all words and punctuation symbols in the corpus or in the specified
        files.

        :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)
         N/A N/A concat N/A N/A N/A self CorpusView path N/A self _read_word_block encoding enc N/A N/A path enc fileid N/A N/A self abspaths fileids True True N/A _read_features N/A N/A self stream N/A N/A N/A features N/A N/A i N/A range 20 N/A N/A line N/A N/A stream readline N/A N/A line N/A N/A features N/A N/A N/A features extend N/A N/A re findall FEATURES line N/A features N/A _read_review_block N/A N/A self stream N/A N/A N/A True N/A N/A line N/A N/A stream readline N/A N/A line N/A N/A N/A N/A title_match N/A N/A re match TITLE line N/A title_match N/A N/A review N/A Review title N/A N/A N/A N/A title_match group 1 strip N/A N/A True N/A N/A oldpos N/A N/A stream tell N/A line N/A N/A stream readline N/A N/A line N/A N/A N/A review N/A N/A N/A re match TITLE line N/A N/A N/A N/A stream seek oldpos N/A N/A review N/A feats N/A N/A re findall FEATURES line N/A notes N/A N/A re findall NOTES line N/A sent N/A N/A re findall SENT line N/A sent N/A N/A sent N/A N/A N/A self _word_tokenizer tokenize N/A sent N/A 0 N/A review_line N/A ReviewLine sent sent features feats notes notes N/A N/A N/A review add_line review_line N/A _read_sent_block N/A N/A self stream N/A N/A N/A sents N/A N/A review N/A N/A self _read_review_block stream N/A N/A N/A N/A sents extend N/A sent N/A sent N/A N/A review sents N/A sents N/A _read_word_block N/A N/A self stream N/A N/A N/A words N/A N/A i N/A range 20 N/A N/A line N/A N/A stream readline N/A sent N/A N/A re findall SENT line N/A sent N/A N/A N/A N/A words extend N/A N/A N/A self _word_tokenizer tokenize N/A sent N/A 0 N/A words N/A N/A