def get_lexical_relations(ccg_xml_trees):
// Get tokens from all CCG trees and de-normalize them.
// (e.g. remove the preceding underscore).
tokens = list(itertools.chain(*[get_tokens_from_ccg_tree(ccg) for ccg in ccg_xml_trees]))
// For every token pair, extract linguistic relationships.
relations_to_pairs = defaultdict(list)
token_pairs = list(itertools.product(tokens, tokens))
for i, (t1, t2) in enumerate(token_pairs):
After Change
def get_lexical_relations(doc):
// Get tokens from all CCG trees and de-normalize them.
// (e.g. remove the preceding underscore).
tokens = doc.xpath("//token/@base")
// For every token pair, extract linguistic relationships.
relations_to_pairs = defaultdict(list)
token_pairs = list(itertools.product(tokens, tokens))
for i, (t1, t2) in enumerate(token_pairs):