class_docstr: A probabilistic non-projective dependency parser.
  
  Nonprojective dependencies allows for "crossing branches" in the parse tree
  which is necessary for representing particular linguistic phenomena, or even
  typical parses in some languages.  This parser follows the MST parsing
  algorithm, outlined in McDonald(2005), which likens the search for the best
  non-projective parse to finding the maximum spanning tree in a weighted
  directed graph.
  
  >>> class Scorer(DependencyScorerI):
  ...     def train(self, graphs):
  ...         pass
  ...
  ...     def score(self, graph):
  ...         return [
  ...             [[], [5],  [1],  [1]],
  ...             [[], [],   [11], [4]],
  ...             [[], [10], [],   [5]],
  ...             [[], [8],  [8],  []],
  ...         ]
  
  
  >>> npp = ProbabilisticNonprojectiveParser()
  >>> npp.train([], Scorer())
  
  >>> parses = npp.parse(['v1', 'v2', 'v3'], [None, None, None])
  >>> len(list(parses))
  1
  
  Rule based example
  
  >>> from nltk.grammar import DependencyGrammar
  
  >>> grammar = DependencyGrammar.fromstring('''
  ... 'taught' -> 'play' | 'man'
  ... 'man' -> 'the' | 'in'
  ... 'in' -> 'corner'
  ... 'corner' -> 'the'
  ... 'play' -> 'golf' | 'dachshund' | 'to'
  ... 'dachshund' -> 'his'
  ... ''')
  
  >>> ndp = NonprojectiveDependencyParser(grammar)
  >>> parses = ndp.parse(['the', 'man', 'in', 'the', 'corner', 'taught', 'his', 'dachshund', 'to', 'play', 'golf'])
  >>> len(list(parses))
  4
class_docstr_tok: ["A","probabilistic","non-projective","dependency","parser",".","Nonprojective","dependencies","allows","for","``","crossing","branches","''","in","the","parse","tree","which","is","necessary","for","representing","particular","linguistic","phenomena",",","or","even","typical","parses","in","some","languages",".","This","parser","follows","the","MST","parsing","algorithm",",","outlined","in","McDonald","(","2005",")",",","which","likens","the","search","for","the","best","non-projective","parse","to","finding","the","maximum","spanning","tree","in","a","weighted","directed","graph",".",">",">",">","class","Scorer","(","DependencyScorerI",")",":","...","def","train","(","self",",","graphs",")",":","...","pass","...","...","def","score","(","self",",","graph",")",":","...","return","[","...","[","[","]",",","[","5","]",",","[","1","]",",","[","1","]","]",",","...","[","[","]",",","[","]",",","[","11","]",",","[","4","]","]",",","...","[","[","]",",","[","10","]",",","[","]",",","[","5","]","]",",","...","[","[","]",",","[","8","]",",","[","8","]",",","[","]","]",",","...","]",">",">",">","npp","=","ProbabilisticNonprojectiveParser","(",")",">",">",">","npp.train","(","[","]",",","Scorer","(",")",")",">",">",">","parses","=","npp.parse","(","[","'v1","'",",","'v2","'",",","'v3","'","]",",","[","None",",","None",",","None","]",")",">",">",">","len","(","list","(","parses",")",")","1","Rule","based","example",">",">",">","from","nltk.grammar","import","DependencyGrammar",">",">",">","grammar","=","DependencyGrammar.fromstring","(","``","'","...","'taught","'","-",">","'play","'","|","'man'","...","'man","'","-",">","'the","'","|","'in'","...","'in","'","-",">","'corner'","...","'corner","'","-",">","'the'","...","'play","'","-",">","'golf","'","|","'dachshund","'","|","'to'","...","'dachshund","'","-",">","'his'","...","``","'",")",">",">",">","ndp","=","NonprojectiveDependencyParser","(","grammar",")",">",">",">","parses","=","ndp.parse","(","[","'the","'",",","'man","'",",","'in","'",",","'the","'",",","'corner","'",",","'taught","'",",","'his","'",",","'dachshund","'",",","'to","'",",","'play","'",",","'golf","'","]",")",">",">",">","len","(","list","(","parses",")",")","4"]
docstr: Returns the source of the best incoming arc to the
  node with address: node_index
  
  :type node_index: integer.
  :param node_index: The address of the 'destination' node,
      the node that is arced to.
docstr_tok: ["Returns","the","source","of","the","best","incoming","arc","to","the","node","with","address",":","node_index",":","type","node_index",":","integer",".",":","param","node_index",":","The","address","of","the","'destination","'","node",",","the","node","that","is","arced","to","."]
code: def best_incoming_arc(self, node_index):
      """
      Returns the source of the best incoming arc to the
      node with address: node_index
  
      :type node_index: integer.
      :param node_index: The address of the 'destination' node,
          the node that is arced to.
      """
      originals = self.compute_original_indexes([node_index])
      logger.debug("originals: %s", originals)
  
      max_arc = None
      max_score = None
      for row_index in range(len(self.scores)):
          for col_index in range(len(self.scores[row_index])):
              if col_index in originals and (
                  max_score is None
                  or self.scores[row_index][col_index] > max_score
              ):
                  max_score = self.scores[row_index][col_index]
                  max_arc = row_index
                  logger.debug("%s, %s", row_index, col_index)
  
      logger.debug(max_score)
  
      for key in self.inner_nodes:
          replaced_nodes = self.inner_nodes[key]
          if max_arc in replaced_nodes:
              return key
  
      return max_arc
  
imports: import logging
  import math
  from nltk.parse.dependencygraph import DependencyGraph
label_desc: Use image node_id 8 for calling the ProbabilisticNonprojectiveParser obj's underlying member method code with example usage: obj.best_incoming_arc(node_index) and returns: max_arc, key