class_docstr: A probabilistic, projective dependency parser.
  
  This parser returns the most probable projective parse derived from the
  probabilistic dependency grammar derived from the train() method.  The
  probabilistic model is an implementation of Eisner's (1996) Model C, which
  conditions on head-word, head-tag, child-word, and child-tag.  The decoding
  uses a bottom-up chart-based span concatenation algorithm that's identical
  to the one utilized by the rule-based projective parser.
  
  Usage example
  
  >>> from nltk.parse.dependencygraph import conll_data2
  
  >>> graphs = [
  ... DependencyGraph(entry) for entry in conll_data2.split('\n\n') if entry
  ... ]
  
  >>> ppdp = ProbabilisticProjectiveDependencyParser()
  >>> ppdp.train(graphs)
  
  >>> sent = ['Cathy', 'zag', 'hen', 'wild', 'zwaaien', '.']
  >>> list(ppdp.parse(sent))
  [Tree('zag', ['Cathy', 'hen', Tree('zwaaien', ['wild', '.'])])]
class_docstr_tok: ["A","probabilistic",",","projective","dependency","parser",".","This","parser","returns","the","most","probable","projective","parse","derived","from","the","probabilistic","dependency","grammar","derived","from","the","train","(",")","method",".","The","probabilistic","model","is","an","implementation","of","Eisner","'s","(","1996",")","Model","C",",","which","conditions","on","head-word",",","head-tag",",","child-word",",","and","child-tag",".","The","decoding","uses","a","bottom-up","chart-based","span","concatenation","algorithm","that","'s","identical","to","the","one","utilized","by","the","rule-based","projective","parser",".","Usage","example",">",">",">","from","nltk.parse.dependencygraph","import","conll_data2",">",">",">","graphs","=","[","...","DependencyGraph","(","entry",")","for","entry","in","conll_data2.split","(","'\\n\\n","'",")","if","entry","...","]",">",">",">","ppdp","=","ProbabilisticProjectiveDependencyParser","(",")",">",">",">","ppdp.train","(","graphs",")",">",">",">","sent","=","[","'Cathy","'",",","'zag","'",",","'hen","'",",","'wild","'",",","'zwaaien","'",",","'",".","'","]",">",">",">","list","(","ppdp.parse","(","sent",")",")","[","Tree","(","'zag","'",",","[","'Cathy","'",",","'hen","'",",","Tree","(","'zwaaien","'",",","[","'wild","'",",","'",".","'","]",")","]",")","]"]
docstr: Trains a ProbabilisticDependencyGrammar based on the list of input
  DependencyGraphs.  This model is an implementation of Eisner's (1996)
  Model C, which derives its statistics from head-word, head-tag,
  child-word, and child-tag relationships.
  
  :param graphs: A list of dependency graphs to train from.
  :type: list(DependencyGraph)
docstr_tok: ["Trains","a","ProbabilisticDependencyGrammar","based","on","the","list","of","input","DependencyGraphs",".","This","model","is","an","implementation","of","Eisner","'s","(","1996",")","Model","C",",","which","derives","its","statistics","from","head-word",",","head-tag",",","child-word",",","and","child-tag","relationships",".",":","param","graphs",":","A","list","of","dependency","graphs","to","train","from",".",":","type",":","list","(","DependencyGraph",")"]
code: def train(self, graphs):
      """
      Trains a ProbabilisticDependencyGrammar based on the list of input
      DependencyGraphs.  This model is an implementation of Eisner's (1996)
      Model C, which derives its statistics from head-word, head-tag,
      child-word, and child-tag relationships.
  
      :param graphs: A list of dependency graphs to train from.
      :type: list(DependencyGraph)
      """
      productions = []
      events = defaultdict(int)
      tags = {}
      for dg in graphs:
          for node_index in range(1, len(dg.nodes)):
              # children = dg.nodes[node_index]['deps']
              children = list(
                  chain.from_iterable(
                      dg.nodes[node_index]["deps"].values()
                  )
              )
  
              nr_left_children = dg.left_children(node_index)
              nr_right_children = dg.right_children(node_index)
              nr_children = nr_left_children + nr_right_children
              for child_index in range(
                  0 - (nr_left_children + 1), nr_right_children + 2
              ):
                  head_word = dg.nodes[node_index]["word"]
                  head_tag = dg.nodes[node_index]["tag"]
                  if head_word in tags:
                      tags[head_word].add(head_tag)
                  else:
                      tags[head_word] = {head_tag}
                  child = "STOP"
                  child_tag = "STOP"
                  prev_word = "START"
                  prev_tag = "START"
                  if child_index < 0:
                      array_index = child_index + nr_left_children
                      if array_index >= 0:
                          child = dg.nodes[children[array_index]][
                              "word"
                          ]
                          child_tag = dg.nodes[children[array_index]][
                              "tag"
                          ]
                      if child_index != -1:
                          prev_word = dg.nodes[
                              children[array_index + 1]
                          ]["word"]
                          prev_tag = dg.nodes[
                              children[array_index + 1]
                          ]["tag"]
                      if child != "STOP":
                          productions.append(
                              DependencyProduction(head_word, [child])
                          )
                      head_event = "(head ({} {}) (mods ({}, {}, {}) left))".format(
                          child,
                          child_tag,
                          prev_tag,
                          head_word,
                          head_tag,
                      )
                      mod_event = "(mods ({}, {}, {}) left))".format(
                          prev_tag,
                          head_word,
                          head_tag,
                      )
                      events[head_event] += 1
                      events[mod_event] += 1
                  elif child_index > 0:
                      array_index = child_index + nr_left_children - 1
                      if array_index < nr_children:
                          child = dg.nodes[children[array_index]][
                              "word"
                          ]
                          child_tag = dg.nodes[children[array_index]][
                              "tag"
                          ]
                      if child_index != 1:
                          prev_word = dg.nodes[
                              children[array_index - 1]
                          ]["word"]
                          prev_tag = dg.nodes[
                              children[array_index - 1]
                          ]["tag"]
                      if child != "STOP":
                          productions.append(
                              DependencyProduction(head_word, [child])
                          )
                      head_event = "(head ({} {}) (mods ({}, {}, {}) right))".format(
                          child,
                          child_tag,
                          prev_tag,
                          head_word,
                          head_tag,
                      )
                      mod_event = "(mods ({}, {}, {}) right))".format(
                          prev_tag,
                          head_word,
                          head_tag,
                      )
                      events[head_event] += 1
                      events[mod_event] += 1
      self._grammar = ProbabilisticDependencyGrammar(
          productions, events, tags
      )
  
imports: from collections import defaultdict
  from functools import total_ordering
  from itertools import chain
  from nltk.grammar import DependencyGrammar, DependencyProduction, ProbabilisticDependencyGrammar
  from nltk.internals import raise_unorderable_types
  from nltk.parse.dependencygraph import DependencyGraph
label_desc: Use image node_id 4 for calling the ProbabilisticProjectiveDependencyParser obj's underlying member method code with example usage: obj.train(graphs) without return types