I'm working with the Stanford Parser in ruby and want to search for all nodes of a tree with a particular label name. This is the recursive method i have coded so far
def searchTreeWithLabel(tree,lablename,listOfNodes)
if tree.instance_of?(StanfordParser::Tree)
if tree.lable.toString == lablename then
listOfNodes << tree
else
tree.children.each { |c| searchTreeWithLabel(c, lablename, listOfNodes)}
end
end
listOfNodes
end
i want the method to return a list of Tree nodes that have the label as labelname