class_docstr: Corpus reader for the XML version of the CHILDES corpus.
  The CHILDES corpus is available at ``https://childes.talkbank.org/``. The XML
  version of CHILDES is located at ``https://childes.talkbank.org/data-xml/``.
  Copy the needed parts of the CHILDES XML corpus into the NLTK data directory
  (``nltk_data/corpora/CHILDES/``).
  
  For access to the file text use the usual nltk functions,
  ``words()``, ``sents()``, ``tagged_words()`` and ``tagged_sents()``.
class_docstr_tok: ["Corpus","reader","for","the","XML","version","of","the","CHILDES","corpus",".","The","CHILDES","corpus","is","available","at","``","https",":","\/\/childes.talkbank.org\/","``",".","The","XML","version","of","CHILDES","is","located","at","``","https",":","\/\/childes.talkbank.org\/data-xml\/","``",".","Copy","the","needed","parts","of","the","CHILDES","XML","corpus","into","the","NLTK","data","directory","(","``","nltk_data\/corpora\/CHILDES\/","``",")",".","For","access","to","the","file","text","use","the","usual","nltk","functions",",","``","words","(",")","``",",","``","sents","(",")","``",",","``","tagged_words","(",")","``","and","``","tagged_sents","(",")","``","."]
code: def _get_words(
      self,
      fileid,
      speaker,
      sent,
      stem,
      relation,
      pos,
      strip_space,
      replace,
  ):
      if (
          isinstance(speaker, str) and speaker != "ALL"
      ):  # ensure we have a list of speakers
          speaker = [speaker]
      xmldoc = ElementTree.parse(fileid).getroot()
      # processing each xml doc
      results = []
      for xmlsent in xmldoc.findall(".//{%s}u" % NS):
          sents = []
          # select speakers
          if speaker == "ALL" or xmlsent.get("who") in speaker:
              for xmlword in xmlsent.findall(".//{%s}w" % NS):
                  infl = None
                  suffixStem = None
                  suffixTag = None
                  # getting replaced words
                  if replace and xmlsent.find(
                      f".//{{{NS}}}w/{{{NS}}}replacement"
                  ):
                      xmlword = xmlsent.find(
                          f".//{{{NS}}}w/{{{NS}}}replacement/{{{NS}}}w"
                      )
                  elif replace and xmlsent.find(
                      f".//{{{NS}}}w/{{{NS}}}wk"
                  ):
                      xmlword = xmlsent.find(f".//{{{NS}}}w/{{{NS}}}wk")
                  # get text
                  if xmlword.text:
                      word = xmlword.text
                  else:
                      word = ""
                  # strip tailing space
                  if strip_space:
                      word = word.strip()
                  # stem
                  if relation or stem:
                      try:
                          xmlstem = xmlword.find(".//{%s}stem" % NS)
                          word = xmlstem.text
                      except AttributeError as e:
                          pass
                      # if there is an inflection
                      try:
                          xmlinfl = xmlword.find(
                              f".//{{{NS}}}mor/{{{NS}}}mw/{{{NS}}}mk"
                          )
                          word += "-" + xmlinfl.text
                      except:
                          pass
                      # if there is a suffix
                      try:
                          xmlsuffix = xmlword.find(
                              ".//{%s}mor/{%s}mor-post/{%s}mw/{%s}stem"
                              % (NS, NS, NS, NS)
                          )
                          suffixStem = xmlsuffix.text
                      except AttributeError:
                          suffixStem = ""
                      if suffixStem:
                          word += "~" + suffixStem
                  # pos
                  if relation or pos:
                      try:
                          xmlpos = xmlword.findall(".//{%s}c" % NS)
                          xmlpos2 = xmlword.findall(".//{%s}s" % NS)
                          if xmlpos2 != []:
                              tag = (
                                  xmlpos[0].text + ":" + xmlpos2[0].text
                              )
                          else:
                              tag = xmlpos[0].text
                      except (AttributeError, IndexError) as e:
                          tag = ""
                      try:
                          xmlsuffixpos = xmlword.findall(
                              ".//{%s}mor/{%s}mor-post/{%s}mw/{%s}pos/{%s}c"
                              % (NS, NS, NS, NS, NS)
                          )
                          xmlsuffixpos2 = xmlword.findall(
                              ".//{%s}mor/{%s}mor-post/{%s}mw/{%s}pos/{%s}s"
                              % (NS, NS, NS, NS, NS)
                          )
                          if xmlsuffixpos2:
                              suffixTag = (
                                  xmlsuffixpos[0].text
                                  + ":"
                                  + xmlsuffixpos2[0].text
                              )
                          else:
                              suffixTag = xmlsuffixpos[0].text
                      except:
                          pass
                      if suffixTag:
                          tag += "~" + suffixTag
                      word = (word, tag)
                  # relational
                  # the gold standard is stored in
                  # <mor></mor><mor type="trn"><gra type="grt">
                  if relation == True:
                      for xmlstem_rel in xmlword.findall(
                          f".//{{{NS}}}mor/{{{NS}}}gra"
                      ):
                          if not xmlstem_rel.get("type") == "grt":
                              word = (
                                  word[0],
                                  word[1],
                                  xmlstem_rel.get("index")
                                  + "|"
                                  + xmlstem_rel.get("head")
                                  + "|"
                                  + xmlstem_rel.get("relation"),
                              )
                          else:
                              word = (
                                  word[0],
                                  word[1],
                                  word[2],
                                  word[0],
                                  word[1],
                                  xmlstem_rel.get("index")
                                  + "|"
                                  + xmlstem_rel.get("head")
                                  + "|"
                                  + xmlstem_rel.get("relation"),
                              )
                      try:
                          for xmlpost_rel in xmlword.findall(
                              f".//{{{NS}}}mor/{{{NS}}}mor-post/{{{NS}}}gra"
                          ):
                              if not xmlpost_rel.get("type") == "grt":
                                  suffixStem = (
                                      suffixStem[0],
                                      suffixStem[1],
                                      xmlpost_rel.get("index")
                                      + "|"
                                      + xmlpost_rel.get("head")
                                      + "|"
                                      + xmlpost_rel.get("relation"),
                                  )
                              else:
                                  suffixStem = (
                                      suffixStem[0],
                                      suffixStem[1],
                                      suffixStem[2],
                                      suffixStem[0],
                                      suffixStem[1],
                                      xmlpost_rel.get("index")
                                      + "|"
                                      + xmlpost_rel.get("head")
                                      + "|"
                                      + xmlpost_rel.get("relation"),
                                  )
                      except:
                          pass
                  sents.append(word)
              if sent or relation:
                  results.append(sents)
              else:
                  results.extend(sents)
      return LazyMap(lambda x: x, results)
  
imports: import re
  from collections import defaultdict
  from nltk.corpus.reader.util import concat
  from nltk.corpus.reader.xmldocs import ElementTree, XMLCorpusReader
  from nltk.util import LazyConcatenation, LazyMap, flatten
label_desc: Use image node_id 15 for calling the CHILDESCorpusReader obj's underlying member method code with example usage: obj._get_words(fileid, speaker, sent, stem, relation, pos, strip_space, replace) and returns: LazyMap