class_docstr: A base class for "corpus reader" classes, each of which can be
  used to read a specific corpus format.  Each individual corpus
  reader instance is used to read a specific corpus, consisting of
  one or more files under a common root directory.  Each file is
  identified by its ``file identifier``, which is the relative path
  to the file from the root directory.
  
  A separate subclass is defined for each corpus format.  These
  subclasses define one or more methods that provide 'views' on the
  corpus contents, such as ``words()`` (for a list of words) and
  ``parsed_sents()`` (for a list of parsed sentences).  Called with
  no arguments, these methods will return the contents of the entire
  corpus.  For most corpora, these methods define one or more
  selection arguments, such as ``fileids`` or ``categories``, which can
  be used to select which portion of the corpus should be returned.
class_docstr_tok: ["A","base","class","for","``","corpus","reader","''","classes",",","each","of","which","can","be","used","to","read","a","specific","corpus","format",".","Each","individual","corpus","reader","instance","is","used","to","read","a","specific","corpus",",","consisting","of","one","or","more","files","under","a","common","root","directory",".","Each","file","is","identified","by","its","``","file","identifier","``",",","which","is","the","relative","path","to","the","file","from","the","root","directory",".","A","separate","subclass","is","defined","for","each","corpus","format",".","These","subclasses","define","one","or","more","methods","that","provide","'views","'","on","the","corpus","contents",",","such","as","``","words","(",")","``","(","for","a","list","of","words",")","and","``","parsed_sents","(",")","``","(","for","a","list","of","parsed","sentences",")",".","Called","with","no","arguments",",","these","methods","will","return","the","contents","of","the","entire","corpus",".","For","most","corpora",",","these","methods","define","one","or","more","selection","arguments",",","such","as","``","fileids","``","or","``","categories","``",",","which","can","be","used","to","select","which","portion","of","the","corpus","should","be","returned","."]
docstr: :type root: PathPointer or str
  :param root: A path pointer identifying the root directory for
      this corpus.  If a string is specified, then it will be
      converted to a ``PathPointer`` automatically.
  :param fileids: A list of the files that make up this corpus.
      This list can either be specified explicitly, as a list of
      strings; or implicitly, as a regular expression over file
      paths.  The absolute path for each file will be constructed
      by joining the reader's root to each file name.
  :param encoding: The default unicode encoding for the files
      that make up the corpus.  The value of ``encoding`` can be any
      of the following:
  
      - A string: ``encoding`` is the encoding name for all files.
      - A dictionary: ``encoding[file_id]`` is the encoding
        name for the file whose identifier is ``file_id``.  If
        ``file_id`` is not in ``encoding``, then the file
        contents will be processed using non-unicode byte strings.
      - A list: ``encoding`` should be a list of ``(regexp, encoding)``
        tuples.  The encoding for a file whose identifier is ``file_id``
        will be the ``encoding`` value for the first tuple whose
        ``regexp`` matches the ``file_id``.  If no tuple's ``regexp``
        matches the ``file_id``, the file contents will be processed
        using non-unicode byte strings.
      - None: the file contents of all files will be
        processed using non-unicode byte strings.
  :param tagset: The name of the tagset used by this corpus, to be used
        for normalizing or converting the POS tags returned by the
        ``tagged_...()`` methods.
docstr_tok: [":","type","root",":","PathPointer","or","str",":","param","root",":","A","path","pointer","identifying","the","root","directory","for","this","corpus",".","If","a","string","is","specified",",","then","it","will","be","converted","to","a","``","PathPointer","``","automatically",".",":","param","fileids",":","A","list","of","the","files","that","make","up","this","corpus",".","This","list","can","either","be","specified","explicitly",",","as","a","list","of","strings",";","or","implicitly",",","as","a","regular","expression","over","file","paths",".","The","absolute","path","for","each","file","will","be","constructed","by","joining","the","reader","'s","root","to","each","file","name",".",":","param","encoding",":","The","default","unicode","encoding","for","the","files","that","make","up","the","corpus",".","The","value","of","``","encoding","``","can","be","any","of","the","following",":","-","A","string",":","``","encoding","``","is","the","encoding","name","for","all","files",".","-","A","dictionary",":","``","encoding","[","file_id","]","``","is","the","encoding","name","for","the","file","whose","identifier","is","``","file_id","``",".","If","``","file_id","``","is","not","in","``","encoding","``",",","then","the","file","contents","will","be","processed","using","non-unicode","byte","strings",".","-","A","list",":","``","encoding","``","should","be","a","list","of","``","(","regexp",",","encoding",")","``","tuples",".","The","encoding","for","a","file","whose","identifier","is","``","file_id","``","will","be","the","``","encoding","``","value","for","the","first","tuple","whose","``","regexp","``","matches","the","``","file_id","``",".","If","no","tuple","'s","``","regexp","``","matches","the","``","file_id","``",",","the","file","contents","will","be","processed","using","non-unicode","byte","strings",".","-","None",":","the","file","contents","of","all","files","will","be","processed","using","non-unicode","byte","strings",".",":","param","tagset",":","The","name","of","the","tagset","used","by","this","corpus",",","to","be","used","for","normalizing","or","converting","the","POS","tags","returned","by","the","``","tagged_","...","(",")","``","methods","."]
code: def __init__(self, root, fileids, encoding="utf8", tagset=None):
      """
      :type root: PathPointer or str
      :param root: A path pointer identifying the root directory for
          this corpus.  If a string is specified, then it will be
          converted to a ``PathPointer`` automatically.
      :param fileids: A list of the files that make up this corpus.
          This list can either be specified explicitly, as a list of
          strings; or implicitly, as a regular expression over file
          paths.  The absolute path for each file will be constructed
          by joining the reader's root to each file name.
      :param encoding: The default unicode encoding for the files
          that make up the corpus.  The value of ``encoding`` can be any
          of the following:
  
          - A string: ``encoding`` is the encoding name for all files.
          - A dictionary: ``encoding[file_id]`` is the encoding
            name for the file whose identifier is ``file_id``.  If
            ``file_id`` is not in ``encoding``, then the file
            contents will be processed using non-unicode byte strings.
          - A list: ``encoding`` should be a list of ``(regexp, encoding)``
            tuples.  The encoding for a file whose identifier is ``file_id``
            will be the ``encoding`` value for the first tuple whose
            ``regexp`` matches the ``file_id``.  If no tuple's ``regexp``
            matches the ``file_id``, the file contents will be processed
            using non-unicode byte strings.
          - None: the file contents of all files will be
            processed using non-unicode byte strings.
      :param tagset: The name of the tagset used by this corpus, to be used
            for normalizing or converting the POS tags returned by the
            ``tagged_...()`` methods.
      """
      # Convert the root to a path pointer, if necessary.
      if isinstance(root, str) and not isinstance(root, PathPointer):
          m = re.match(r"(.*\.zip)/?(.*)$|", root)
          zipfile, zipentry = m.groups()
          if zipfile:
              root = ZipFilePathPointer(zipfile, zipentry)
          else:
              root = FileSystemPathPointer(root)
      elif not isinstance(root, PathPointer):
          raise TypeError(
              "CorpusReader: expected a string or a PathPointer"
          )
  
      # If `fileids` is a regexp, then expand it.
      if isinstance(fileids, str):
          fileids = find_corpus_fileids(root, fileids)
  
      self._fileids = fileids
      """A list of the relative paths for the fileids that make up
          this corpus."""
  
      self._root = root
      """The root directory for this corpus."""
  
      self._readme = "README"
      self._license = "LICENSE"
      self._citation = "citation.bib"
  
      # If encoding was specified as a list of regexps, then convert
      # it to a dictionary.
      if isinstance(encoding, list):
          encoding_dict = {}
          for fileid in self._fileids:
              for x in encoding:
                  (regexp, enc) = x
                  if re.match(regexp, fileid):
                      encoding_dict[fileid] = enc
                      break
          encoding = encoding_dict
  
      self._encoding = encoding
      """The default unicode encoding for the fileids that make up
             this corpus.  If ``encoding`` is None, then the file
             contents are processed using byte strings."""
      self._tagset = tagset
  
imports: import os
  import re
  from collections import defaultdict
  from itertools import chain
  from nltk.corpus.reader.util import *
  from nltk.data import FileSystemPathPointer, PathPointer, ZipFilePathPointer
label_desc: Use image node_id 1 to create a new CorpusReader object  with example: obj = CorpusReader(root, fileids, encoding, tagset)