# Path: epitran/ligaturize.py
# def ligaturize(text):
#     """Convert text to employ non-standard ligatures
# 
#     Args:
#         text (unicode): IPA text to Convert
# 
#     Return:
#         unicode: non-standard IPA text with phonetic ligatures for affricates
#     """
#     mapping = [(u't͡s', u'ʦ'),
#                (u't͡ʃ', u'ʧ'),
#                (u't͡ɕ', u'ʨ'),
#                (u'd͡z', u'ʣ'),
#                (u'd͡ʒ', u'ʤ'),
#                (u'd͡ʑ', u'ʥ'),]
#     for from_, to_ in mapping:
#         text = text.replace(from_, to_)
#     return text
# 
# Path: epitran/puncnorm.py
# class PuncNorm(object):
#     def __init__(self):
#         """Constructs a punctuation normalization object"""
#         self.puncnorm = self._load_punc_norm_map()
# 
#     def _load_punc_norm_map(self):
#         """Load the map table for normalizing 'down' punctuation."""
#         path = pkg_resources.resource_filename(__name__, 'data/puncnorm.csv')
#         with open(path, 'rb') as f:
#             reader = csv.reader(f, encoding='utf-8', delimiter=str(','), quotechar=str('"'))
#             next(reader)
#             return {punc: norm for (punc, norm) in reader}
# 
#     def norm(self, text):
#         """Apply punctuation normalization to a string of text
# 
#         Args:
#             text (unicode): text to normalize_punc
# 
#         Returns:
#             unicode: text with normalized punctuation
#         """
#         new_text = []
#         for c in text:
#             if c in self.puncnorm:
#                 new_text.append(self.puncnorm[c])
#             else:
#                 new_text.append(c)
#         return ''.join(new_text)
# 
#     def __iter__(self):
#         return iter(self.puncnorm)
# 
#     def __getitem__(self, key):
#         return self.puncnorm[key]


import logging
import os.path
import string
import sys
import unicodedata
import pkg_resources
import regex as re
import panphon
import unicodecsv as csv
    import subprocess32 as subprocess
    import subprocess
from epitran.ligaturize import ligaturize
from epitran.puncnorm import PuncNorm
    def arpa_to_ipa(self, arpa_text, ligatures=False):
        arpa_text = arpa_text.strip()
        arpa_list = self.arpa_text_to_list(arpa_text)
        arpa_list = map(lambda d: re.sub(r'\d', '', d), arpa_list)
        ipa_list = map(lambda d: self.arpa_map[d], arpa_list)
        text = ''.join(ipa_list)
        return text

    def english_g2p(self, english):
        """Stub for English G2P function to be overwritten by subclasses"""
        return ""

    def transliterate(self, text, normpunc=False, ligatures=False):
        """Convert English text to IPA transcription

        Args:
            text (unicode): English text
            normpunc (bool): if True, normalize punctuation downward
            ligatures (bool): if True, use non-standard ligatures instead of
                              standard IPA
        """
        text = unicodedata.normalize('NFC', text)
        acc = []
        for chunk in self.chunk_re.findall(text):
            if self.letter_re.match(chunk):
                acc.append(self.english_g2p(chunk))
            else:
                acc.append(chunk)
        text = ''.join(acc)
        text = self.puncnorm.norm(text) if normpunc else text

# Path: epitran/ligaturize.py
# def ligaturize(text):
#     """Convert text to employ non-standard ligatures
# 
#     Args:
#         text (unicode): IPA text to Convert
# 
#     Return:
#         unicode: non-standard IPA text with phonetic ligatures for affricates
#     """
#     mapping = [(u't͡s', u'ʦ'),
#                (u't͡ʃ', u'ʧ'),
#                (u't͡ɕ', u'ʨ'),
#                (u'd͡z', u'ʣ'),
#                (u'd͡ʒ', u'ʤ'),
#                (u'd͡ʑ', u'ʥ'),]
#     for from_, to_ in mapping:
#         text = text.replace(from_, to_)
#     return text
# 
# Path: epitran/puncnorm.py
# class PuncNorm(object):
#     def __init__(self):
#         """Constructs a punctuation normalization object"""
#         self.puncnorm = self._load_punc_norm_map()
# 
#     def _load_punc_norm_map(self):
#         """Load the map table for normalizing 'down' punctuation."""
#         path = pkg_resources.resource_filename(__name__, 'data/puncnorm.csv')
#         with open(path, 'rb') as f:
#             reader = csv.reader(f, encoding='utf-8', delimiter=str(','), quotechar=str('"'))
#             next(reader)
#             return {punc: norm for (punc, norm) in reader}
# 
#     def norm(self, text):
#         """Apply punctuation normalization to a string of text
# 
#         Args:
#             text (unicode): text to normalize_punc
# 
#         Returns:
#             unicode: text with normalized punctuation
#         """
#         new_text = []
#         for c in text:
#             if c in self.puncnorm:
#                 new_text.append(self.puncnorm[c])
#             else:
#                 new_text.append(c)
#         return ''.join(new_text)
# 
#     def __iter__(self):
#         return iter(self.puncnorm)
# 
#     def __getitem__(self, key):
#         return self.puncnorm[key]


# Path: epitran/flite.py
import logging
import os.path
import string
import sys
import unicodedata
import pkg_resources
import regex as re
import panphon
import unicodecsv as csv
    import subprocess32 as subprocess
    import subprocess
from epitran.ligaturize import ligaturize
from epitran.puncnorm import PuncNorm

    def arpa_to_ipa(self, arpa_text, ligatures=False):
        arpa_text = arpa_text.strip()
        arpa_list = self.arpa_text_to_list(arpa_text)
        arpa_list = map(lambda d: re.sub(r'\d', '', d), arpa_list)
        ipa_list = map(lambda d: self.arpa_map[d], arpa_list)
        text = ''.join(ipa_list)
        return text

    def english_g2p(self, english):
        """Stub for English G2P function to be overwritten by subclasses"""
        return ""

    def transliterate(self, text, normpunc=False, ligatures=False):
        """Convert English text to IPA transcription

        Args:
            text (unicode): English text
            normpunc (bool): if True, normalize punctuation downward
            ligatures (bool): if True, use non-standard ligatures instead of
                              standard IPA
        """
        text = unicodedata.normalize('NFC', text)
        acc = []
        for chunk in self.chunk_re.findall(text):
            if self.letter_re.match(chunk):
                acc.append(self.english_g2p(chunk))
            else:
                acc.append(chunk)
        text = ''.join(acc)
        text = self.puncnorm.norm(text) if normpunc else text

        text = ligaturize(text) if (ligatures or self.ligatures) else text