def find_triples(tokens, left_dependency_label='NSUBJ', head_part_of_speech='VERB', right_dependency_label='DOBJ'):
 for (head, token) in enumerate(tokens):
  if (token['partOfSpeech']['tag'] == head_part_of_speech):
   children = dependents(tokens, head)
   left_deps = []
   right_deps = []
   for child in children:
    child_token = tokens[child]
    child_dep_label = child_token['dependencyEdge']['label']
    if (child_dep_label == left_dependency_label):
     left_deps.append(child)
    elif (child_dep_label == right_dependency_label):
     right_deps.append(child)
   for left_dep in left_deps:
    for right_dep in right_deps:
     (yield (left_dep, head, right_dep))

def find_triples ( tokens , left_dependency_label = 'NSUBJ' , head_part_of_speech = 'VERB' , right_dependency_label = 'DOBJ' ) : for ( head , token ) in enumerate ( tokens ) : if ( token [ 'partOfSpeech' ] [ 'tag' ] == head_part_of_speech ) : children = dependents ( tokens , head ) left_deps = [ ] right_deps = [ ] for child in children : child_token = tokens [ child ] child_dep_label = child_token [ 'dependencyEdge' ] [ 'label' ] if ( child_dep_label == left_dependency_label ) : left_deps . append ( child ) elif ( child_dep_label == right_dependency_label ) : right_deps . append ( child ) for left_dep in left_deps : for right_dep in right_deps : ( yield ( left_dep , head , right_dep ) )
generator function that searches the given tokens with the given part of speech tag .