Constructing a tree using Python

Posted by stealthspy on Stack Overflow See other posts from Stack Overflow or by stealthspy
Published on 2012-09-08T03:31:31Z Indexed on 2012/09/08 3:37 UTC
Read the original article Hit count: 171

I am trying to implement a unranked boolean retrieval. For this, I need to construct a tree and perform a DFS to retrieve documents. I have the leaf nodes but I am having difficulty to construct the tree.

Eg: query = OR ( AND (maria sharapova) tennis)

Result:

      OR
     |   |
     AND tennis
     | | 
  maria sharapova

I traverse the tree using DFS and calculate the boolean equivalent of certain document ids to identify the required document from the corpus. Can someone help me with the design of this using python? I have parsed the query and retrieved the leaf nodes for now.

© Stack Overflow or respective owner

Related posts about python

Related posts about algorithm