class_docstr: Reads constituency parses from the WSJ part of the Penn Tree Bank from the LDC.
  This ``DatasetReader`` is designed for use with a span labelling model, so
  it enumerates all possible spans in the sentence and returns them, along with gold
  labels for the relevant spans present in a gold tree, if provided.
  
  Parameters
  ----------
  token_indexers : ``Dict[str, TokenIndexer]``, optional (default=``{"tokens": SingleIdTokenIndexer()}``)
      We use this to define the input representation for the text.  See :class:`TokenIndexer`.
      Note that the `output` tags will always correspond to single token IDs based on how they
      are pre-tokenised in the data file.
  use_pos_tags : ``bool``, optional, (default = ``True``)
      Whether or not the instance should contain gold POS tags
      as a field.
  lazy : ``bool``, optional, (default = ``False``)
      Whether or not instances can be consumed lazily.
class_docstr_tok: ["Reads","constituency","parses","from","the","WSJ","part","of","the","Penn","Tree","Bank","from","the","LDC",".","This","``","DatasetReader","``","is","designed","for","use","with","a","span","labelling","model",",","so","it","enumerates","all","possible","spans","in","the","sentence","and","returns","them",",","along","with","gold","labels","for","the","relevant","spans","present","in","a","gold","tree",",","if","provided",".","Parameters","--","--","--","--","--","token_indexers",":","``","Dict","[","str",",","TokenIndexer","]","``",",","optional","(","default=","``","{","``","tokens","''",":","SingleIdTokenIndexer","(",")","}","``",")","We","use","this","to","define","the","input","representation","for","the","text",".","See",":","class",":","`","TokenIndexer","`",".","Note","that","the","`","output","`","tags","will","always","correspond","to","single","token","IDs","based","on","how","they","are","pre-tokenised","in","the","data","file",".","use_pos_tags",":","``","bool","``",",","optional",",","(","default","=","``","True","``",")","Whether","or","not","the","instance","should","contain","gold","POS","tags","as","a","field",".","lazy",":","``","bool","``",",","optional",",","(","default","=","``","False","``",")","Whether","or","not","instances","can","be","consumed","lazily","."]
code: def _read(self, file_path):
      # if `file_path` is a URL, redirect to the cache
      file_path = cached_path(file_path)
      directory, filename = os.path.split(file_path)
      logger.info(
          "Reading instances from lines in file at: %s", file_path
      )
      for parse in BracketParseCorpusReader(
          root=directory, fileids=[filename]
      ).parsed_sents():
          self._strip_functional_tags(parse)
          # This is un-needed and clutters the label space.
          # All the trees also contain a root S node.
          if parse.label() == "VROOT":
              parse = parse[0]
          pos_tags = (
              [x[1] for x in parse.pos()]
              if self._use_pos_tags
              else None
          )
          yield self.text_to_instance(parse.leaves(), pos_tags, parse)
  
file_path: magnitude/pymagnitude/third_party/allennlp/data/dataset_readers/penn_tree_bank.py
imports: from __future__ import absolute_import
  import logging
  import os
  from nltk.corpus.reader.bracket_parse import BracketParseCorpusReader
  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 TextField, SpanField, SequenceLabelField, ListField, MetadataField, Field
  from allennlp.data.instance import Instance
  from allennlp.data.token_indexers import TokenIndexer, SingleIdTokenIndexer
  from allennlp.data.tokenizers import Token
  from allennlp.data.dataset_readers.dataset_utils.span_utils import enumerate_spans
  from allennlp.common.checks import ConfigurationError
label_desc: Use image node_id 2 for calling the PennTreeBankConstituencySpanDatasetReader obj's underlying member method code with example usage: obj._read(file_path) without return types