Skip to content

Commit

Permalink
fix: add debug print in syntax match
Browse files Browse the repository at this point in the history
  • Loading branch information
k4black committed Nov 16, 2023
1 parent 6052988 commit 8d17961
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion codebleu/syntax_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ def get_all_sub_trees(root_node):
cand_sexps = [x[0] for x in get_all_sub_trees(candidate_tree)]
ref_sexps = [x[0] for x in get_all_sub_trees(reference_tree)]

print('cand_sexps')
for tree, depth in get_all_sub_trees(candidate_tree):
print(' ', depth, tree)
print('ref_sexps')
for tree, depth in get_all_sub_trees(reference_tree):
print(' ', depth, tree)

# TODO: fix, now we count number of reference subtrees matching candidate,
# but we should count number of candidate subtrees matching reference
# See (4) in "3.2 Syntactic AST Match" of https://arxiv.org/pdf/2009.10297.pdf
Expand All @@ -83,6 +90,7 @@ def get_all_sub_trees(root_node):
match_count_candidate_to_reference += 1

total_count += len(ref_sexps)

print(f'match_count {match_count} / {total_count}')
print(f'match_count_fixed {match_count_candidate_to_reference} / {total_count}')
score = match_count / total_count
return score

0 comments on commit 8d17961

Please sign in to comment.