-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* trying to edit formatting with autopep8 to conform to pep8 * fixed several things, among which flake8 version, tox.ini formatting, lots in the source code format, ran it once to make sure it still works * added babelon table creation, also fixed creation of prompts wo missing translations in any language, added a dropna to make sure #52 is solved
- Loading branch information
Showing
3 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
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
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,41 @@ | ||
""" | ||
Create babelon complying tables from .xlsx that was sent to us | ||
""" | ||
|
||
import pandas as pd | ||
#tr_lang_code = "es" | ||
#tr_lang_code = "nl" | ||
#tr_lang_code = "de" | ||
tr_lang_code = "tr" | ||
#tr_lang = "spanish-1" | ||
#tr_lang = "dutch" | ||
#tr_lang = "german" | ||
tr_lang = "turkish-1" | ||
|
||
|
||
data_path = "/Users/leonardo/data/translate_missing/" | ||
data_file = data_path + "missing_hp_" + tr_lang + ".xlsx" | ||
|
||
langs = ["it", "de", "es", "cs", "tr", ] # "zh" has a different structure, it's already been done | ||
# German, manually edit based on excel as well | ||
|
||
babelon_names = ["source_language", "source_value", "subject_id", "predicate_id", | ||
"translation_language", "translation_value", "translation_status", | ||
"translator", "translator_expertise", "translation_date", | ||
] | ||
|
||
|
||
df = pd.DataFrame(columns=babelon_names) | ||
df[["source_value", "translation_value"]] = pd.read_excel(data_file, header=None, usecols="A:B") | ||
df[["source_value", "subject_id"]] = df["source_value"].str.split('(', n=1, expand=True) | ||
df['subject_id'] = df['subject_id'].str.replace(')','') | ||
df['translation_value'] = df['translation_value'].str.replace(r'\(.*\)', '', regex=True) | ||
df["source_language"] = "en" | ||
df["predicate_id"] = "rdfs:label" | ||
df["translation_language"] = tr_lang_code | ||
df["translation_status"] = "CANDIDATE" | ||
df["translator"] = "DeepL" | ||
df["translator_expertise"] = "ALGORITHM" | ||
df["translation_date"] = "2024-09-11" | ||
|
||
df.to_excel(data_path + "hp-" + tr_lang_code + "-babelon.xlsx", index=False) |
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