title: Python list to Parse tree
body: <p>In Python, I have an input of list like following-</p>
  
  <pre><code>[('S', ['NP', 'VP']),
  ('A', ['V', 'NP']),
  ('VP', ['V', 'NP']),
  ('NP', ['DET', 'NP']),
  ('N', "'mouse'"),
  ('NP', "'mouse'"),
  ('DET', "'the'"),
  ('V', "'saw'"),
  ('N', "'Ron'"),
  ('NP', "'Ron'")]
  </code></pre>
  
  <p>This is the result of the following CYK algorithm-</p>
  
  <pre><code>S -&gt; NP VP
  VP -&gt; A NP | V NP
  NP -&gt; N N | DET NP | 'chocolate' | 'cat' | 'John' | 'Ron' | 'mouse'
  DET -&gt; 'the'
  N -&gt; 'chocolate' | 'cat' | 'John' | 'Ron' | 'mouse'
  V -&gt; 'saw' | 'bought' | 'ate'
  A -&gt; V NP
  </code></pre>
  
  <p>The string that I want to match with is "Ron saw the mouse"</p>
  
  <p>I want to relate output like this-</p>
  
  <pre><code>(S (NP Ron) (VP (V saw) (NP (DET the) (NP mouse))))
  </code></pre>
  
  <p>I am not sure how the algorithm should be constructed especially with an ambiguous algorithm which may contain multiple outputs. 
  How should I construct code? Any suggestion what should be a better approach with/without recursion?</p>
  
  <p>UPDATE---</p>
  
  <p>I managed to get a single exact parse tree after adding extra parents and child nodes position values with the input list. But my problem doesn't solve with the ambiguous sentence. </p>