Skip to content

Commit

Permalink
scribe-org#14 add generate step to jupyter
Browse files Browse the repository at this point in the history
  • Loading branch information
wkyoshida committed Nov 9, 2022
1 parent ced4a49 commit cbf36c8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/scribe_data/extract_transform/process_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import emoji
import json

from scribe_data.load.update_utils import get_language_iso
from scribe_data.load.update_utils import get_language_iso, get_path_from_process_unicode


def gen_emoji_autosuggestions(
Expand Down Expand Up @@ -52,7 +52,8 @@ def gen_emoji_autosuggestions(

iso = get_language_iso(language)

cldr_file_path = f"node_modules/cldr-annotations-full/annotations/{iso}/annotations.json"
path_to_scribe_org = get_path_from_process_unicode()
cldr_file_path = f"{path_to_scribe_org}/Scribe-Data/node_modules/cldr-annotations-full/annotations/{iso}/annotations.json"

with open(cldr_file_path, "r") as file:
cldr_data = json.load(file)
Expand Down
32 changes: 32 additions & 0 deletions src/scribe_data/load/gen_emoji_suggestions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@
"sys.path.append(pwd)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9ca127ab",
"metadata": {},
"outputs": [],
"source": [
"from scribe_data.extract_transform.process_unicode import gen_emoji_autosuggestions"
]
},
{
"cell_type": "markdown",
"id": "2add942e",
Expand All @@ -91,6 +101,28 @@
". $HOME/.nvm/nvm.sh # Pick up the 'npm' command\n",
"npm install"
]
},
{
"cell_type": "markdown",
"id": "2add942e",
"metadata": {},
"source": [
"# Generate"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fe631670",
"metadata": {},
"outputs": [],
"source": [
"# Languages: French, German, Italian, Portuguese, Russian, Spanish, Swedish\n",
"language = \"French\"\n",
"autosuggest_dict = gen_emoji_autosuggestions(\n",
" language=language\n",
")"
]
}
],
"metadata": {
Expand Down
7 changes: 7 additions & 0 deletions src/scribe_data/load/update_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ def get_path_from_update_data():
return "../../../.."


def get_path_from_process_unicode():
"""
Returns the directory path from process_unicode.py to scribe-org.
"""
return "../../../.."


def get_path_from_process_wiki():
"""
Returns the directory path from process_wiki.py to scribe-org.
Expand Down

0 comments on commit cbf36c8

Please sign in to comment.