Skip to content

Commit

Permalink
Update generate_emoji_keyword.py with additional changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekikereabasi-Nk committed Oct 17, 2024
1 parent 5a47465 commit 3c41c6d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
# Parse the command-line arguments.
args = parser.parse_args()

# Call the generate_emoji_keyword function with optional parameters.
# Define the main language
LANGUAGE = "Hindustani" # Change to a grouped language if needed


# Call the generate_emoji_keyword function with optional parameters
generate_emoji_keyword(
LANGUAGE,
args.file_path,
Expand Down
32 changes: 28 additions & 4 deletions src/scribe_data/unicode/generate_emoji_keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def generate_emoji_keyword(
region=None,
sub_languages=None,
):

# Define grouped languages and their sub-languages.
grouped_languages = {
"Hindustani": ["Hindi", "Urdu"],
Expand All @@ -42,6 +43,18 @@ def generate_emoji_keyword(
# If the language is a grouped language, handle its sub-languages.
if language in grouped_languages:
# If specific sub-languages are provided, only process those.

# Define grouped languages and their sub-languages.
grouped_languages = {
"Hindustani": ["Hindi", "Urdu"],
"Norwegian": ["Bokmål", "Nynorsk"],
# Add more grouped languages as needed.
}

# If the language is a grouped language, handle its sub-languages.
if language in grouped_languages:
# If specific sub-languages are provided, only process those.

sub_languages_to_process = sub_languages or grouped_languages[language]

for sub_lang in sub_languages_to_process:
Expand All @@ -55,9 +68,15 @@ def generate_emoji_keyword(
region=region,
)


# Export the generated emoji keywords for the sub-language.
if emoji_keywords_dict:
# Save the file with the sub-language included in the file name.

# Export the generated emoji keywords for the sub-language.
if emoji_keywords_dict:
# Save the file with the sub-language included in the file name.

export_file_path = f"{file_path}_{sub_lang}.json"
export_formatted_data(
file_path=export_file_path,
Expand All @@ -67,22 +86,27 @@ def generate_emoji_keyword(
data_type="emoji-keywords",
)


# If it's not a grouped language, process it as a single language.

else:
# generate emoji keywords for the given language.
emoji_keywords_dict = gen_emoji_lexicon(
# Generate emoji keywords for the given language.

emoji_keywords_dict = gen_emoji_lexicon(
language=language,
emojis_per_keyword=emojis_per_keyword,
gender=gender,
region=region,
)


# Export the generated emoji keywords for the language.
if emoji_keywords_dict:

if emoji_keywords_dict:
export_formatted_data(
file_path=file_path,
formatted_data=emoji_keywords_dict,
query_data_in_use=True,
language=language,
data_type="emoji-keywords",
)
)

0 comments on commit 3c41c6d

Please sign in to comment.