def compareTrees(tree_path1, tree_path2): tree1 = getTrees(tree_path1) tree2 = getTrees(tree_path2) treedict = {} for t in tree1: treedict[t.key] = t match = 0 non_match = 0 for t in tree2: if t.key in treedict: match += 1 else: non_match += 1 print "match:%d nonmatch:%d" %(match, non_match)
def matchTreesWithScriptsFromURLList(tree_path, url_path): trees = getTrees(tree_path) treedict = {} for tree in trees: treedict[tree.key] = tree scriptdict, count_dict, json_count = extractScriptsAndGenerateASTNodesFromURLListFinerBlock(url_path) match_script = 0 match_uniq_script = 0 nonmatch_script = 0 nonmatch_uniq_script = 0 nonmatch_tree = 0 nomatch_list = [] for key in scriptdict: if key in treedict: match_uniq_script += len(scriptdict[key]) match_script += count_dict[key] else: nonmatch_uniq_script += len(scriptdict[key]) nonmatch_script += count_dict[key] nonmatch_tree += 1 print "non match script: %s " %(scriptdict[key][0][0]) print "matched scripts:%d[%d] \n nonmatched scripts:%d[%d] nonmatch_tree:%d" \ %(match_uniq_script,match_script, nonmatch_uniq_script, nonmatch_script, nonmatch_tree)