-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate words from Russian to other Scribe languages #89
Merged
andrewtavis
merged 14 commits into
scribe-org:main
from
shashank-iitbhu:translate-from-russian
Mar 18, 2024
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dfaf4d7
added translate funcs
shashank-iitbhu 389cb8f
added language path func
shashank-iitbhu afe9ed8
added doc strings
shashank-iitbhu 42bd042
added doc string
shashank-iitbhu ac7488e
batch processing for translations
shashank-iitbhu ccb5364
translate from russian
shashank-iitbhu b36f5fb
fix
shashank-iitbhu 8ffcb22
fix
shashank-iitbhu 2fcdaf6
fix
shashank-iitbhu efd432e
interruption signal call moved to utils
shashank-iitbhu d2a7d48
interruption signal call moved to utils
shashank-iitbhu cc41160
Merge branch 'main' into translate-from-russian
andrewtavis eebd63e
#77 formatting for translation, adding dependencies, trying Mac CI
andrewtavis cd64c8b
Fix workflow: remove Mac and add language-data back in
andrewtavis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modify the
src_lang
variable to specify the source language for the translations.Keep the rest of the
translate_words.py
script unchanged.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥🔥🔥 Nice, @shashank-iitbhu :) I'll take a bit more of a look at this, and maybe we can move this to an all caps var at the top. I can handle this myself though 😊