class_docstr: Reads tokens and their sentiment labels from the Stanford Sentiment Treebank.
  
  The Stanford Sentiment Treebank comes with labels
  from 0 to 4. ``"5-class"`` uses these labels as is. ``"3-class"`` converts the
  problem into one of identifying whether a sentence is negative, positive, or
  neutral sentiment. In this case, 0 and 1 are grouped as label 0 (negative sentiment),
  2 is converted to label 1 (neutral sentiment) and 3 and 4 are grouped as label 2
  (positive sentiment). ``"2-class"`` turns it into a binary classification problem
  between positive and negative sentiment. 0 and 1 are grouped as the label 0
  (negative sentiment), 2 (neutral) is discarded, and 3 and 4 are grouped as the label 1
  (positive sentiment).
  
  Expected format for each input line: a linearized tree, where nodes are labeled
  by their sentiment.
  
  The output of ``read`` is a list of ``Instance`` s with the fields:
      tokens: ``TextField`` and
      label: ``LabelField``
  
  Parameters
  ----------
  token_indexers : ``Dict[str, TokenIndexer]``, optional (default=``{"tokens": SingleIdTokenIndexer()}``)
      We use this to define the input representation for the text.  See :class:`TokenIndexer`.
  use_subtrees : ``bool``, optional, (default = ``False``)
      Whether or not to use sentiment-tagged subtrees.
  granularity : ``str``, optional (default = ``"5-class"``)
      One of ``"5-class"``, ``"3-class"``, or ``"2-class"``, indicating the number
      of sentiment labels to use.
  lazy : ``bool``, optional, (default = ``False``)
      Whether or not instances can be read lazily.
class_docstr_tok: ["Reads","tokens","and","their","sentiment","labels","from","the","Stanford","Sentiment","Treebank",".","The","Stanford","Sentiment","Treebank","comes","with","labels","from","0","to","4",".","``","``","5-class","''","``","uses","these","labels","as","is",".","``","``","3-class","''","``","converts","the","problem","into","one","of","identifying","whether","a","sentence","is","negative",",","positive",",","or","neutral","sentiment",".","In","this","case",",","0","and","1","are","grouped","as","label","0","(","negative","sentiment",")",",","2","is","converted","to","label","1","(","neutral","sentiment",")","and","3","and","4","are","grouped","as","label","2","(","positive","sentiment",")",".","``","``","2-class","''","``","turns","it","into","a","binary","classification","problem","between","positive","and","negative","sentiment",".","0","and","1","are","grouped","as","the","label","0","(","negative","sentiment",")",",","2","(","neutral",")","is","discarded",",","and","3","and","4","are","grouped","as","the","label","1","(","positive","sentiment",")",".","Expected","format","for","each","input","line",":","a","linearized","tree",",","where","nodes","are","labeled","by","their","sentiment",".","The","output","of","``","read","``","is","a","list","of","``","Instance","``","s","with","the","fields",":","tokens",":","``","TextField","``","and","label",":","``","LabelField","``","Parameters","--","--","--","--","--","token_indexers",":","``","Dict","[","str",",","TokenIndexer","]","``",",","optional","(","default=","``","{","``","tokens","''",":","SingleIdTokenIndexer","(",")","}","``",")","We","use","this","to","define","the","input","representation","for","the","text",".","See",":","class",":","`","TokenIndexer","`",".","use_subtrees",":","``","bool","``",",","optional",",","(","default","=","``","False","``",")","Whether","or","not","to","use","sentiment-tagged","subtrees",".","granularity",":","``","str","``",",","optional","(","default","=","``","``","5-class","''","``",")","One","of","``","``","5-class","''","``",",","``","``","3-class","''","``",",","or","``","``","2-class","''","``",",","indicating","the","number","of","sentiment","labels","to","use",".","lazy",":","``","bool","``",",","optional",",","(","default","=","``","False","``",")","Whether","or","not","instances","can","be","read","lazily","."]
code: def __init__(
      self,
      token_indexers=None,
      use_subtrees=False,
      granularity="5-class",
      lazy=False,
  ):
      super(StanfordSentimentTreeBankDatasetReader, self).__init__(
          lazy=lazy
      )
      self._token_indexers = token_indexers or {
          "tokens": SingleIdTokenIndexer()
      }
      self._use_subtrees = use_subtrees
      allowed_granularities = ["5-class", "3-class", "2-class"]
      if granularity not in allowed_granularities:
          raise ConfigurationError(
              "granularity is {}, but expected one of: {}".format(
                  granularity, allowed_granularities
              )
          )
      self._granularity = granularity
  
file_path: magnitude/pymagnitude/third_party/allennlp/data/dataset_readers/stanford_sentiment_tree_bank.py
imports: from __future__ import with_statement
  from __future__ import absolute_import
  import logging
  from nltk.tree import Tree
  from allennlp.common.file_utils import cached_path
  from allennlp.data.dataset_readers.dataset_reader import DatasetReader
  from allennlp.data.fields import LabelField, TextField, Field
  from allennlp.data.instance import Instance
  from allennlp.data.token_indexers import TokenIndexer, SingleIdTokenIndexer
  from allennlp.data.tokenizers import Token
  from allennlp.common.checks import ConfigurationError
  from io import open
label_desc: Use image node_id 1 to create a new StanfordSentimentTreeBankDatasetReader object from inherited base classes: DatasetReader with example: obj = StanfordSentimentTreeBankDatasetReader(token_indexers, use_subtrees, granularity, lazy)