Skip to content

Commit

Permalink
Inference items added
Browse files Browse the repository at this point in the history
  • Loading branch information
Supriya090 committed Feb 8, 2024
0 parents commit d2eb86b
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
18 changes: 18 additions & 0 deletions interactive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
source_lang=en
target_lang=$1
input_file=$2
beam=$3
nbest=$4


fairseq-interactive corpus-bin \
--path transformer/checkpoint_best.pt \
--task translation_multi_simple_epoch \
--beam $beam \
--nbest $nbest \
--source-lang $source_lang \
--target-lang $target_lang \
--encoder-langtok "tgt" \
--lang-dict lang_list.txt \
--input $input_file \
--lang-pairs en-as,en-bn,en-brx,en-gom,en-gu,en-hi,en-kn,en-ks,en-mai,en-ml,en-mni,en-mr,en-ne,en-or,en-pa,en-sa,en-sd,en-si,en-ta,en-te,en-ur > output/${source_lang}_${target_lang}.txt
22 changes: 22 additions & 0 deletions lang_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
en
as
bn
brx
gom
gu
hi
kn
ks
mai
ml
mni
mr
ne
or
pa
sa
sd
si
ta
te
ur
16 changes: 16 additions & 0 deletions load_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import sys
import re

line = sys.argv[1]
line = re.sub(r'[^a-zA-Z ]+', '', line.strip().lower())

words = line.split(' ')

input_words = []

for word in words:
input_words.append(' '.join(list(word)))

with open('source/source.txt', 'w') as file:
for word in (input_words):
file.write(word + "\n")
16 changes: 16 additions & 0 deletions transliterate_word.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
while getopts l:i:b:n:r: module
do
case "${module}" in
l)lang_abr=${OPTARG};;
i)input_file=${OPTARG};;
b)beam=${OPTARG};;
n)nbest=${OPTARG};;
r)rerank=${OPTARG};;
esac
done

while IFS= read -r line; do
python3 load_input.py "$line"
bash interactive.sh $lang_abr 'source/source.txt' $beam $nbest
python3 generate_result_files_txt.py $lang_abr $rerank
done < $input_file

0 comments on commit d2eb86b

Please sign in to comment.