Last active
November 24, 2019 14:59
-
-
Save fomkin/e8553e620c2867eae88e4f8551368c43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def PPR(ref, hyp): | |
def find_words_before_commas(tokens): | |
words_before_commas = set() | |
for i, token in enumerate(tokens): | |
if token == "," and i > 0: | |
word = tokens[i-1] | |
words_before_commas.add(word) | |
return words_before_commas | |
hyp_words_before_commas = find_words_before_commas(hyp.split()) | |
ref_words_before_commas = find_words_before_commas(ref.split()) | |
diff = hyp_words_before_commas.symmetric_difference(ref_words_before_commas) | |
return len(diff) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment