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: Parses the list of tokens subject to the projectivity constraint
  and the productions in the parser's grammar.  This uses a method
  similar to the span-concatenation algorithm defined in Eisner (1996).
  It returns the most probable parse derived from the parser's
  probabilistic dependency grammar.
docstr_tok: ["Parses","the","list","of","tokens","subject","to","the","projectivity","constraint","and","the","productions","in","the","parser","'s","grammar",".","This","uses","a","method","similar","to","the","span-concatenation","algorithm","defined","in","Eisner","(","1996",")",".","It","returns","the","most","probable","parse","derived","from","the","parser's","probabilistic","dependency","grammar","."]
code: def parse(self, tokens):
      """
      Parses the list of tokens subject to the projectivity constraint
      and the productions in the parser's grammar.  This uses a method
      similar to the span-concatenation algorithm defined in Eisner (1996).
      It returns the most probable parse derived from the parser's
      probabilistic dependency grammar.
      """
      self._tokens = list(tokens)
      chart = []
      for i in range(0, len(self._tokens) + 1):
          chart.append([])
          for j in range(0, len(self._tokens) + 1):
              chart[i].append(ChartCell(i, j))
              if i == j + 1:
                  if tokens[i - 1] in self._grammar._tags:
                      for tag in self._grammar._tags[tokens[i - 1]]:
                          chart[i][j].add(
                              DependencySpan(
                                  i - 1, i, i - 1, [-1], [tag]
                              )
                          )
                  else:
                      print(
                          "No tag found for input token '%s', parse is impossible."
                          % tokens[i - 1]
                      )
                      return []
      for i in range(1, len(self._tokens) + 1):
          for j in range(i - 2, -1, -1):
              for k in range(i - 1, j, -1):
                  for span1 in chart[k][j]._entries:
                      for span2 in chart[i][k]._entries:
                          for newspan in self.concatenate(span1, span2):
                              chart[i][j].add(newspan)
      trees = []
      max_parse = None
      max_score = 0
      for parse in chart[len(self._tokens)][0]._entries:
          conll_format = ""
          malt_format = ""
          for i in range(len(tokens)):
              malt_format += "%s\t%s\t%d\t%s\n" % (
                  tokens[i],
                  "null",
                  parse._arcs[i] + 1,
                  "null",
              )
              # conll_format += '\t%d\t%s\t%s\t%s\t%s\t%s\t%d\t%s\t%s\t%s\n' % (i+1, tokens[i], tokens[i], parse._tags[i], parse._tags[i], 'null', parse._arcs[i] + 1, 'null', '-', '-')
              # Modify to comply with recent change in dependency graph such that there must be a ROOT element.
              conll_format += (
                  "\t%d\t%s\t%s\t%s\t%s\t%s\t%d\t%s\t%s\t%s\n"
                  % (
                      i + 1,
                      tokens[i],
                      tokens[i],
                      parse._tags[i],
                      parse._tags[i],
                      "null",
                      parse._arcs[i] + 1,
                      "ROOT",
                      "-",
                      "-",
                  )
              )
          dg = DependencyGraph(conll_format)
          score = self.compute_prob(dg)
          trees.append((score, dg.tree()))
      trees.sort()
      return (tree for (score, tree) in trees)
  
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 2 for calling the ProbabilisticProjectiveDependencyParser obj's underlying member method code with example usage: obj.parse(tokens) and returns: unknown, list