Skip to content

Commit

Permalink
Merge pull request #122 from roedoejet/master
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
roedoejet authored Aug 25, 2021
2 parents bc84959 + 841618d commit b3b587f
Show file tree
Hide file tree
Showing 36 changed files with 1,572 additions and 324 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ before_install:
install:
# Install Python dependencies
- pip3 install -r /home/travis/build/roedoejet/g2p/requirements.txt
# Install g2p
- cd /home/travis/build/roedoejet/g2p && pip3 install -e .
# Legal check: make sure we don't introduce GPL dependencies
- pip3 install pip-licenses
- if pip-licenses | grep -v 'Artistic License' | grep -v LGPL | grep GNU; then echo 'Please avoid introducing *GPL dependencies'; false; fi
# Install testing requirements
- pip3 install coverage
- pip3 install coveralls
- pip3 install gunicorn
# Install g2p
- cd /home/travis/build/roedoejet/g2p && pip3 install -e .

before_script:
- gunicorn --worker-class eventlet -w 1 g2p.app:APP --no-sendfile --bind 0.0.0.0:5000 --daemon
Expand Down
2 changes: 1 addition & 1 deletion g2p/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def update_docs():
LOGGER.info('Updated API documentation')


g2p_api = Blueprint('resources.g2p', __name__)
g2p_api = Blueprint('resources-g2p', __name__)

CORS(g2p_api)

Expand Down
2 changes: 1 addition & 1 deletion g2p/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def scan(lang, path):
pattern = "[^" + mapped_string + filter_chars + ".]"
prog = re.compile(pattern)

with open(path, "r") as file:
with open(path, "r", encoding="utf8") as file:
data = normalize(file.read(), "NFD")
if not case_sensitive:
data = data.lower()
Expand Down
11 changes: 8 additions & 3 deletions g2p/mappings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, mapping=None, abbreviations: Union[str, DefaultDict[str, List
# yes, they should
self.allowable_kwargs = ['language_name', 'display_name', 'mapping', 'in_lang',
'out_lang', 'out_delimiter', 'as_is', 'case_sensitive', 'rule_ordering',
'escape_special', 'norm_form', 'prevent_feeding', 'reverse']
'escape_special', 'norm_form', 'prevent_feeding', 'reverse', 'type']
self.kwargs = OrderedDict(kwargs)
self.processed = False
if isinstance(abbreviations, defaultdict) or not abbreviations:
Expand All @@ -101,6 +101,8 @@ def __init__(self, mapping=None, abbreviations: Union[str, DefaultDict[str, List
elif 'id' in self.kwargs:
loaded_config = self.find_mapping_by_id(self.kwargs['id'])
self.process_loaded_config(loaded_config)
elif self.kwargs.get("type", "") == "unidecode":
self.mapping = []
else:
raise exceptions.MalformedLookup()
if self.abbreviations:
Expand Down Expand Up @@ -182,10 +184,13 @@ def process_loaded_config(self, config):
''' For a mapping loaded from a file, take the keyword arguments and supply them to the
Mapping, and get any abbreviations data.
'''
self.mapping = config['mapping_data']
if config.get("type", "") == "unidecode":
self.mapping = []
else:
self.mapping = config['mapping_data']
self.abbreviations = config.get('abbreviations_data', None)
mapping_kwargs = OrderedDict(
{k: v for k, v in config.items() if k in self.allowable_kwargs})
self.abbreviations = config.get('abbreviations_data', None)
# Merge kwargs, but prioritize kwargs that initialized the Mapping
self.kwargs = {**mapping_kwargs, **self.kwargs}

Expand Down
2 changes: 1 addition & 1 deletion g2p/mappings/create_fallback_mapping.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from unidecode import unidecode
from text_unidecode import unidecode

from g2p import make_g2p
from g2p.log import LOGGER
Expand Down
11 changes: 6 additions & 5 deletions g2p/mappings/langs/generated/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,16 @@ mappings:
- authors:
- Generated 2020-09-18 10:40:15.289530
- Updated by hand 2021-02-10 Eric Joanis to handle ejectives
- Update by hand 2021-05-21 Shankhalika Srikanth reorder rules with aspiration
case_sensitive: false
display_name: Tlingit IPA to English IPA
escape_special: false
in_lang: tli-ipa
language_name: Tlingit IPA
mapping: tli-norm-ipa_to_eng-ipa.json
norm_form: NFC
mapping: tli-ipa_to_eng-ipa.json
norm_form: NFD
out_lang: eng-ipa
prevent_feeding: false
prevent_feeding: true
reverse: false
rule_ordering: as-written
- authors:
Expand Down Expand Up @@ -235,7 +236,7 @@ mappings:
reverse: false
rule_ordering: as-written
- authors:
- Generated 2021-03-24 21:42:30.002668
- Generated 2021-08-01 19:37:38.316339
case_sensitive: false
display_name: tau-ipa IPA to eng-ipa IPA
escape_special: false
Expand All @@ -244,7 +245,7 @@ mappings:
mapping: tau-ipa_to_eng-ipa.json
norm_form: NFD
out_lang: eng-ipa
prevent_feeding: true
prevent_feeding: false
reverse: false
rule_ordering: as-written
- authors:
Expand Down
42 changes: 36 additions & 6 deletions g2p/mappings/langs/generated/haa-ipa_to_eng-ipa.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
[
{
"in": "\u0303\u0300",
"out": "\u0303",
"context_before": "",
"context_after": ""
},
{
"in": "\u0303\u030C",
"out": "\u0303",
"context_before": "",
"context_after": ""
},
{
"in": "\u0303\u0302",
"out": "\u0303",
"context_before": "",
"context_after": ""
},
{
"in": "\u0300",
"out": "",
"context_before": "",
"context_after": ""
},
{
"in": "\u030C",
"out": "",
"context_before": "",
"context_after": ""
},
{
"in": "\u0302",
"out": "",
"context_before": "",
"context_after": ""
},
{
"in": "\u207fk",
"out": "nk",
Expand Down Expand Up @@ -347,12 +383,6 @@
"context_before": "",
"context_after": ""
},
{
"in": "\u0303",
"out": "",
"context_before": "",
"context_after": ""
},
{
"in": "\u0259",
"out": "\u0259",
Expand Down
Loading

0 comments on commit b3b587f

Please sign in to comment.