From 3c41c6d653a379c8ef5c49c1b11c9d67b935dbc8 Mon Sep 17 00:00:00 2001 From: Ekikereabasi Nkereuwem Date: Wed, 16 Oct 2024 07:54:46 +0100 Subject: [PATCH] Update generate_emoji_keyword.py with additional changes --- .../emoji_keywords/generate_emoji_keywords.py | 6 +++- .../unicode/generate_emoji_keyword.py | 32 ++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/scribe_data/language_data_extraction/Hindustani/Hindi/emoji_keywords/generate_emoji_keywords.py b/src/scribe_data/language_data_extraction/Hindustani/Hindi/emoji_keywords/generate_emoji_keywords.py index 8bcf81d1a..27be9610a 100644 --- a/src/scribe_data/language_data_extraction/Hindustani/Hindi/emoji_keywords/generate_emoji_keywords.py +++ b/src/scribe_data/language_data_extraction/Hindustani/Hindi/emoji_keywords/generate_emoji_keywords.py @@ -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, diff --git a/src/scribe_data/unicode/generate_emoji_keyword.py b/src/scribe_data/unicode/generate_emoji_keyword.py index e728473ce..5bf7768d6 100644 --- a/src/scribe_data/unicode/generate_emoji_keyword.py +++ b/src/scribe_data/unicode/generate_emoji_keyword.py @@ -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"], @@ -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: @@ -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, @@ -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", - ) +) \ No newline at end of file