views:

60

answers:

1

After a bit further analysis on my requirement.I gained some more clarity..Sorry for presenting an unclear question.

I want to know how can we parse a string with braces of the form((Question)(Left_Node)(right_node)). The question for example wil be of the form if segment size < 1.5,then choose left node,else right.The question can be a dictionary with a key and a value.Left and right node represent a complete left or right half tree.Need to recursively parse the tree till the leaf node is reached.In this manner need to build an decision binary. I am working on speech synthesis,and am new to this python programming,so looking for help in coding,please suggest methods for implementing this kind??

Please answer...

thanks in advance..

A: 

If you can decide on the details of the input format, then use raw python source code. For example you can store your tree in a python dictionary of nodes:

tree = {
    "root": ("a", "b")
    "a": ("c", "d"),
    "b": ("e", "f"),
    "c": (None, None), #No children, a leaf.
    "d": (None, None),
    "e": (None, None),
    "f": (None, None),
}

Now you can parse this tree simply with the python parser.

from tree_data import tree #We're done parsing!

root_node = tree["root"]
left_child = tree[root_node[0]]

Well, if the input format is already specified, then we cannot help you if you don't share the details of that format.

Tadeusz A. Kadłubowski
Thanks you,actually i didnt have complete clarity about what i wanted..ya i am now edit the question..please help me in the implementation...
kaushik