gsarti commited on
Commit
2f9ef10
1 Parent(s): 9938670

Fix keywords

Browse files
Files changed (1) hide show
  1. mt_geneval.py +6 -5
mt_geneval.py CHANGED
@@ -56,7 +56,8 @@ _URL = "https://raw.githubusercontent.com/amazon-science/machine-translation-gen
56
  _CONFIGS = ["sentences", "context"]
57
  _LANGS = ["ar", "fr", "de", "hi", "it", "pt", "ru", "es"]
58
 
59
- r = re.compile('<F>(.+?)</F>')
 
60
 
61
  class MTGenEvalConfig(datasets.BuilderConfig):
62
  def __init__(
@@ -190,10 +191,10 @@ class WmtVat(datasets.GeneratorBasedBuilder):
190
  source_masculine_annotated = f.read().splitlines()
191
  with open(filepaths["reference_masculine_annotated"]) as f:
192
  reference_masculine_annotated = f.read().splitlines()
193
- source_feminine_keywords = [r.findall(s) for s in source_feminine_annotated]
194
- reference_feminine_keywords = [r.findall(s) for s in reference_feminine_annotated]
195
- source_masculine_keywords = [r.findall(s) for s in source_masculine_annotated]
196
- reference_masculine_keywords = [r.findall(s) for s in reference_masculine_annotated]
197
  for i, (sf, rf, sm, rm, sfa, rfa, sma, rma, sfk, rfk, smk, rmk) in enumerate(
198
  zip(
199
  source_feminine, reference_feminine, source_masculine, reference_masculine,
 
56
  _CONFIGS = ["sentences", "context"]
57
  _LANGS = ["ar", "fr", "de", "hi", "it", "pt", "ru", "es"]
58
 
59
+ rexf = re.compile('<F>(.+?)</F>')
60
+ rexm = re.compile('<M>(.+?)</M>')
61
 
62
  class MTGenEvalConfig(datasets.BuilderConfig):
63
  def __init__(
 
191
  source_masculine_annotated = f.read().splitlines()
192
  with open(filepaths["reference_masculine_annotated"]) as f:
193
  reference_masculine_annotated = f.read().splitlines()
194
+ source_feminine_keywords = [rexf.findall(s) for s in source_feminine_annotated]
195
+ reference_feminine_keywords = [rexf.findall(s) for s in reference_feminine_annotated]
196
+ source_masculine_keywords = [rexm.findall(s) for s in source_masculine_annotated]
197
+ reference_masculine_keywords = [rexm.findall(s) for s in reference_masculine_annotated]
198
  for i, (sf, rf, sm, rm, sfa, rfa, sma, rma, sfk, rfk, smk, rmk) in enumerate(
199
  zip(
200
  source_feminine, reference_feminine, source_masculine, reference_masculine,