Skip to content

Commit

Permalink
fix: backtranslation with api and README
Browse files Browse the repository at this point in the history
  • Loading branch information
pprobst committed Nov 27, 2023
1 parent 211e640 commit e6bb563
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Can be used standalone (instructions below) or as part of other programs.
help: ./run_txt_aug.py -h
example usage:
./run_txt_aug.py corpus_1br_10pt_15sept.tok --aug translate random --action delete --maxs 10 --lang en --translate_mode local --append --output out.txt
./run_txt_aug.py corpus_1br_10pt_15sept.tok --aug backtranslate random_del --maxs 5 --lang en --translate_mode google --apend --output out.txt
```

## Offline text generation
Expand Down
2 changes: 1 addition & 1 deletion run_txt_aug.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

"""
example usage:
./txt_aug.py corpus.tok --aug translate random --action delete --maxs 10 --lang en --append
./txt_aug.py corpus.tok --aug translate random_del --maxs 10 --lang en --append
"""


Expand Down
5 changes: 2 additions & 3 deletions text/aug.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,13 @@ def backtranslate_sentences_api(
skips_count += 1
continue
try:
backtranslator = backtranslator.translate(translation)
backtranslation = backtranslator.translate(translation)
backtranslations.append(backtranslation)
except Exception as e:
print(f"[!] Skipping backtranslating sentence '{translation}': {e}")
skips_count += 1
continue
skips_count = 0
backtranslation = backtranslator.translate(translation)
backtranslations.append(backtranslation)
print(f"{sentence} -> {translation} -> {backtranslation}")

return backtranslations
Expand Down

0 comments on commit e6bb563

Please sign in to comment.