Skip to content

Commit

Permalink
fixes #55
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank Mittal <[email protected]>
  • Loading branch information
Shashank Mittal authored and Shashank Mittal committed Jan 16, 2024
1 parent fac762e commit 0b63cea
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ dependencies:
- regex>=2023.8.8
- SPARQLWrapper>=2.0.0
- tensorflow>=2.11.0
- langcodes>=3.0.0
- language_data>=1.0.0
26 changes: 13 additions & 13 deletions src/scribe_data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from importlib import resources
from pathlib import Path
from typing import Any
import langcodes
from langcodes import *

PROJECT_ROOT = "Scribe-Data"

Expand Down Expand Up @@ -154,12 +156,12 @@ def get_language_iso(language: str) -> str:
str
The ISO code for the language.
"""
return _find(
"language",
language,
"iso",
f"{language.capitalize()} is currently not a supported language for ISO conversion.",
)
try:
iso_code = str(langcodes.find(language).language)
return iso_code
except langcodes.LanguageTagError:
raise ValueError(f"{language.capitalize()} is currently not a supported language for ISO conversion.")



def get_language_from_iso(iso: str) -> str:
Expand All @@ -176,13 +178,11 @@ def get_language_from_iso(iso: str) -> str:
str
The name for the language which has an ISO value of iso.
"""
return _find(
"iso",
iso,
"language",
f"{iso.upper()} is currently not a supported ISO language.",
).capitalize()

try:
language_name = str(Language.make(language=iso).display_name())
return language_name
except langcodes.LanguageTagError:
raise ValueError(f"{iso} is currently not a supported ISO language.")

def get_language_words_to_remove(language: str) -> list[str]:
"""
Expand Down
3 changes: 3 additions & 0 deletions tests/load/test_update_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import unittest
import pytest

import sys
sys.path.append('../../src')

from scribe_data import utils


Expand Down

0 comments on commit 0b63cea

Please sign in to comment.