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: Takes a list of nodes that have been identified to belong to a cycle,
  and collapses them into on larger node.  The arcs of all nodes in
  the graph must be updated to account for this.
  
  :type new_node: Node.
  :param new_node: A Node (Dictionary) to collapse the cycle nodes into.
  :type cycle_path: A list of integers.
  :param cycle_path: A list of node addresses, each of which is in the cycle.
  :type g_graph, b_graph, c_graph: DependencyGraph
  :param g_graph, b_graph, c_graph: Graphs which need to be updated.
docstr_tok: ["Takes","a","list","of","nodes","that","have","been","identified","to","belong","to","a","cycle",",","and","collapses","them","into","on","larger","node",".","The","arcs","of","all","nodes","in","the","graph","must","be","updated","to","account","for","this",".",":","type","new_node",":","Node",".",":","param","new_node",":","A","Node","(","Dictionary",")","to","collapse","the","cycle","nodes","into",".",":","type","cycle_path",":","A","list","of","integers",".",":","param","cycle_path",":","A","list","of","node","addresses",",","each","of","which","is","in","the","cycle",".",":","type","g_graph",",","b_graph",",","c_graph",":","DependencyGraph",":","param","g_graph",",","b_graph",",","c_graph",":","Graphs","which","need","to","be","updated","."]
code: def collapse_nodes(
      self, new_node, cycle_path, g_graph, b_graph, c_graph
  ):
      """
      Takes a list of nodes that have been identified to belong to a cycle,
      and collapses them into on larger node.  The arcs of all nodes in
      the graph must be updated to account for this.
  
      :type new_node: Node.
      :param new_node: A Node (Dictionary) to collapse the cycle nodes into.
      :type cycle_path: A list of integers.
      :param cycle_path: A list of node addresses, each of which is in the cycle.
      :type g_graph, b_graph, c_graph: DependencyGraph
      :param g_graph, b_graph, c_graph: Graphs which need to be updated.
      """
      logger.debug("Collapsing nodes...")
      # Collapse all cycle nodes into v_n+1 in G_Graph
      for cycle_node_index in cycle_path:
          g_graph.remove_by_address(cycle_node_index)
      g_graph.add_node(new_node)
      g_graph.redirect_arcs(cycle_path, new_node["address"])
  
imports: import logging
  import math
  from nltk.parse.dependencygraph import DependencyGraph
label_desc: Use image node_id 4 for calling the ProbabilisticNonprojectiveParser obj's underlying member method code with example usage: obj.collapse_nodes(new_node, cycle_path, g_graph, b_graph, c_graph) without return types