-
Notifications
You must be signed in to change notification settings - Fork 69
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
Centralizing the emoji keyword generation logic #379
Closed
Ekikereabasi-Nk
wants to merge
11
commits into
scribe-org:main
from
Ekikereabasi-Nk:centralized-emoji-function
+206
−0
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8238e27
Update generate_emoji_keyword.py with additional changes
Ekikereabasi-Nk 8b05fb8
Update generate_emoji_keywords.py and created common_arg_parser.py fo…
Ekikereabasi-Nk 036c60d
Update generate_emoji_keyword.py with additional changes
Ekikereabasi-Nk 53206be
Update src/scribe_data/unicode/generate_emoji_keyword.py
Ekikereabasi-Nk a72ab70
Updated centralized emoji logic
Ekikereabasi-Nk 1209620
Update generate_emoji_keyword.py with additional changes
Ekikereabasi-Nk c152a31
Update generate_emoji_keyword.py with additional changes
Ekikereabasi-Nk f0feaac
Update generate_emoji_keyword.py with additional changes
Ekikereabasi-Nk a733955
Update generate_emoji_keywords.py and created common_arg_parser.py fo…
Ekikereabasi-Nk f602dc3
Update generate_emoji_keyword.py with additional changes
Ekikereabasi-Nk 84ef9a1
Delete Hindustani emoji_keyword.py file
Ekikereabasi-Nk 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
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,82 @@ | ||
""" | ||
centralized emoji_keyword file | ||
.. raw:: html | ||
<!-- | ||
* Copyright (C) 2024 Scribe | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
--> | ||
""" | ||
|
||
import argparse | ||
import json | ||
from pathlib import Path | ||
|
||
from scribe_data.unicode.process_unicode import gen_emoji_lexicon | ||
from scribe_data.utils import export_formatted_data | ||
|
||
DATA_TYPE = "emoji-keywords" | ||
EMOJIS_PER_KEYWORD = 3 | ||
|
||
# Define the path to the languages JSON file. | ||
LANGUAGES_JSON = Path(__file__).parent / "supported_language.json" | ||
|
||
|
||
def main(file_path): | ||
# Read the language codes and names from the JSON. | ||
with open(LANGUAGES_JSON, "r", encoding="utf-8") as f: | ||
languages = json.load(f) | ||
|
||
for code, language in languages.items(): | ||
print(f"Generating emoji keywords for {language} ({code})...") | ||
|
||
language_dir = file_path / f"{language}" | ||
emoji_dir = language_dir / "emoji_keywords" | ||
init_file = emoji_dir / "__init__.py" | ||
|
||
# Ensure that the emoji_keywords directory and __init__.py file exist. | ||
emoji_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
if not init_file.exists(): | ||
# Create the __init__.py file if it doesn't exist. | ||
init_file.touch() | ||
print(f"Created __init__.py in {emoji_dir}.") | ||
|
||
if emoji_keywords_dict := gen_emoji_lexicon( | ||
language=language, | ||
emojis_per_keyword=EMOJIS_PER_KEYWORD, | ||
): | ||
export_formatted_data( | ||
file_path=emoji_dir / f"{code}_emoji_keywords.json", | ||
formatted_data=emoji_keywords_dict, | ||
query_data_in_use=True, | ||
language=language, | ||
data_type=DATA_TYPE, | ||
) | ||
print(f"Emoji keywords for {language} saved.\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--file-path", required=True, help="Path to save the emoji keywords files." | ||
) | ||
args = parser.parse_args() | ||
|
||
# Ensure the directory exists. | ||
output_dir = Path(args.file_path) | ||
output_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
# Call the main function. | ||
main(output_dir) |
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.
Makes Sense!! Does that mean there's a lot more scope for emoji generation by expanding the demographics? Just confirming. Actually sounds interesting. Can we do anything in reference to this? Maybe expand the emoji generation? What do you say @Ekikereabasi-Nk and @andrewtavis .
Thank you @Ekikereabasi-Nk for the work.