Commit dd5b526b authored by lintangsutawika's avatar lintangsutawika
Browse files

format

parent 04f5697d
upper_pronouns = [ upper_pronouns = [
"A", "A",
"An", "An",
...@@ -13,17 +12,18 @@ upper_pronouns = [ ...@@ -13,17 +12,18 @@ upper_pronouns = [
"Their", "Their",
] ]
def process_doc(dataset):
def process_doc(dataset):
def process_fn(doc): def process_fn(doc):
# The HF implementation of `wsc273` is not `partial evaluation` friendly. # The HF implementation of `wsc273` is not `partial evaluation` friendly.
doc["text"] = doc["text"].replace(" ", " ") doc["text"] = doc["text"].replace(" ", " ")
doc["options"][0] = __normalize_option(doc, doc["options"][0]) doc["options"][0] = __normalize_option(doc, doc["options"][0])
doc["options"][1] = __normalize_option(doc, doc["options"][1]) doc["options"][1] = __normalize_option(doc, doc["options"][1])
return doc return doc
return dataset.map(process_fn) return dataset.map(process_fn)
def __normalize_option(doc, option): def __normalize_option(doc, option):
# Append `'s` to possessive determiner based options. # Append `'s` to possessive determiner based options.
if doc["pronoun"].lower() in ["my", "his", "her", "our", "their"]: if doc["pronoun"].lower() in ["my", "his", "her", "our", "their"]:
...@@ -33,4 +33,4 @@ def __normalize_option(doc, option): ...@@ -33,4 +33,4 @@ def __normalize_option(doc, option):
start_of_sentence = doc["text"][doc["pronoun_loc"] - 2] == "." start_of_sentence = doc["text"][doc["pronoun_loc"] - 2] == "."
if not start_of_sentence and pronoun in upper_pronouns: if not start_of_sentence and pronoun in upper_pronouns:
return option.replace(pronoun, pronoun.lower()) return option.replace(pronoun, pronoun.lower())
return option return option
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment