-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Shashank Mittal <[email protected]>
- Loading branch information
1 parent
ac7488e
commit ccb5364
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/scribe_data/extract_transform/languages/Russian/translations/translate_words.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import json | ||
import os | ||
import signal | ||
import sys | ||
|
||
PATH_TO_SCRIBE_ORG = os.path.dirname(sys.path[0]).split("Scribe-Data")[0] | ||
PATH_TO_SCRIBE_DATA_SRC = f"{PATH_TO_SCRIBE_ORG}Scribe-Data/src" | ||
sys.path.insert(0, PATH_TO_SCRIBE_DATA_SRC) | ||
|
||
from scribe_data.utils import translate_to_other_languages, translation_interrupt_handler | ||
|
||
translate_script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
words_to_translate_path = os.path.join(translate_script_dir, 'words_to_translate.json') | ||
|
||
with open(words_to_translate_path, 'r', encoding='utf-8') as file: | ||
json_data = json.load(file) | ||
|
||
word_list = {} | ||
for item in json_data: | ||
word_list.append(item["word"]) | ||
|
||
src_lang="Russian" | ||
|
||
translations = [] | ||
translated_words_path = os.path.join(translate_script_dir, '../formatted_data/translated_words.json') | ||
if os.path.exists(translated_words_path): | ||
with open(translated_words_path, 'r', encoding='utf-8') as file: | ||
translations = json.load(file) | ||
|
||
signal.signal(signal.SIGINT, lambda sig, frame: translation_interrupt_handler(src_lang, translations)) | ||
|
||
translate_to_other_languages(src_lang, word_list, translations) |