Skip to content

Commit

Permalink
refactor: rename get_langs->get_arpabet_langs to make purpose clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
joanise committed Apr 17, 2023
1 parent 88d5f53 commit 7c5222e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions g2p/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The main entry points for the g2p module are:
- make_g2p() to create a mapper from and lang to another
- make_tokenizer() to create a tokenizeer for a given language
- get_langs() to get the list of languages with a path to eng-arpabet
- get_arpabet_langs() to get the list of languages with a path to eng-arpabet
Basic Usage:
from g2p import make_g2p
Expand All @@ -17,8 +17,8 @@
tokenizer = make_tokenizer(lang)
list_of_tokens = tokenizer.tokenize_text(input_text)
from g2p import get_langs
LANGS, LANG_NAMES = get_langs()
from g2p import get_arpabet_langs
LANGS, LANG_NAMES = get_arpabet_langs()
"""
import sys
from typing import Dict, Optional, Tuple, Union
Expand Down Expand Up @@ -138,7 +138,7 @@ def tokenize_and_map(tokenizer, transducer, input: str):
_lang_names_cache = None


def get_langs():
def get_arpabet_langs():
"""Get the list of language codes and names supported by the g2p library
for mapping to ARPABET.
Expand Down
8 changes: 4 additions & 4 deletions g2p/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import yaml

from g2p import get_langs
from g2p import get_arpabet_langs
from g2p.exceptions import IncorrectFileType, MalformedMapping, RecursionError
from g2p.log import LOGGER
from g2p.mappings import Mapping, utils
Expand Down Expand Up @@ -247,15 +247,15 @@ def test_normalize_to_NFK_with_indices(self):
(e_acute_nfd, [(0, 0), (0, 1)]),
)

def test_get_langs(self):
LANGS, LANG_NAMES = get_langs()
def test_get_arpabet_langs(self):
LANGS, LANG_NAMES = get_arpabet_langs()
self.assertEqual(LANGS, sorted(LANGS))
self.assertEqual(list(LANG_NAMES.keys()), sorted(LANG_NAMES.keys()))
self.assertEqual(LANGS, list(LANG_NAMES.keys()))
self.assertTrue("kwk-umista" in LANG_NAMES)
self.assertTrue("str" in LANG_NAMES)
self.assertGreater(len(LANGS), 40)
LANGS2, LANG_NAMES2 = get_langs()
LANGS2, LANG_NAMES2 = get_arpabet_langs()
self.assertIs(LANGS2, LANGS)
self.assertIs(LANG_NAMES2, LANG_NAMES)

Expand Down

0 comments on commit 7c5222e

Please sign in to comment.