Exemplo n.º 1
0
def _perform_mapping_pre_processing(consonants, vowels, akhand,
                                    composite_letters, various_signs):
    """
    Sets of all consonants and vowel *characters* (not maatras).
    This list is used for the vowel idiosyncracy where 'LETTER A' is placed 
    explicitly if a consonant is followed by a vowel character 
    (not a vowel sign, which is a 'maatra')
    See: insert_explicit_schwa()
    """
    all_consonants = set()
    for each in consonants, akhand, composite_letters:
        for value in each.values():
            all_consonants.update(value)
    vowel_chars = set()
    all_consonants_and_vowels = set(all_consonants)
    for value in vowels.values():
        all_consonants_and_vowels.update(value)
        length = len(value)
        # We assume here that the first value is a vowel char, the second is a
        # vowel sign, and that there are no more than two values
        if length == 2:
            vowel_chars.add(value[0])
        elif length > 2:
            raise Exception(
                "Expected each Braille vowel to map from 2 vowels, but it's mapping from more than 2:\n{0}"
                .format(vowels))
    # Reverse all the braille-to-indic mappings from mappings.py
    # We need a indic-to-bharati-braille mapping for each type of mapping
    indic_to_bb = {}
    for (braille, indic_list) in vowels.items() | consonants.items() | \
                                 various_signs.items() | dashes.items():
        for each in indic_list:
            indic_to_bb[each] = braille
    indic_to_bb_composite = {}
    for (braille,
         devanagari_list) in akhand.items() | composite_letters.items():
        for each in devanagari_list:
            indic_to_bb_composite[each] = braille
    return (all_consonants, frozenset(all_consonants_and_vowels), vowel_chars,
            indic_to_bb, indic_to_bb_composite)
Exemplo n.º 2
0
def _perform_mapping_pre_processing(consonants, vowels, akhand, composite_letters, various_signs):
    """
    Sets of all consonants and vowel *characters* (not maatras).
    This list is used for the vowel idiosyncracy where 'LETTER A' is placed 
    explicitly if a consonant is followed by a vowel character 
    (not a vowel sign, which is a 'maatra')
    See: insert_explicit_schwa()
    """
    all_consonants = set()
    for each in consonants, akhand, composite_letters:
        for value in each.values():
            all_consonants.update(value)
    vowel_chars = set()
    all_consonants_and_vowels = set(all_consonants)
    for value in vowels.values():
        all_consonants_and_vowels.update(value)
        length = len(value)
        # We assume here that the first value is a vowel char, the second is a
        # vowel sign, and that there are no more than two values
        if length == 2:
            vowel_chars.add(value[0])
        elif length > 2:
            raise Exception("Expected each Braille vowel to map from 2 vowels, but it's mapping from more than 2:\n{0}".format(vowels))
    # Reverse all the braille-to-indic mappings from mappings.py
    # We need a indic-to-bharati-braille mapping for each type of mapping
    indic_to_bb = {}
    for (braille, indic_list) in vowels.items() | consonants.items() | \
                                 various_signs.items() | dashes.items():
        for each in indic_list:
            indic_to_bb[each] = braille
    indic_to_bb_composite = {}
    for (braille, devanagari_list) in akhand.items() | composite_letters.items():
        for each in devanagari_list:
            indic_to_bb_composite[each] = braille
    return (all_consonants, frozenset(all_consonants_and_vowels), 
            vowel_chars, indic_to_bb, indic_to_bb_composite)
Exemplo n.º 3
0
# Set of all numbers. Used in translate_math()
number_chars = set()
for value in numbers.values():
    number_chars.update(value)

# Set of all math symbols
all_math_symbols = set()
for value in math_symbols.values():
    all_math_symbols.update(value)

# Reverse all the bharati-braille-to-glyph mappings from mappings.py
# We need a glyph-to-bharati-braille mapping for each type of mapping
# This section converts all the characters common for all Indic scripts
cm_to_bb_punctuation = {}
for (braille, devanagari_list) in punctuation.items() | \
                                  paired_punctuation.items() | dashes.items():
    for each in devanagari_list:
        cm_to_bb_punctuation[each] = braille
cm_to_bb_numbers = {}
for (braille, devanagari_list) in numbers.items():
    for each in devanagari_list:
        cm_to_bb_numbers[each] = braille
cm_to_bb_math_punctuation = {}
for (braille, devanagari_list) in math_punctuation.items():
    for each in devanagari_list:
        cm_to_bb_math_punctuation[each] = braille

####################
#    BEGIN INDIC   #
#  PRE-PROCESSING  #
####################
Exemplo n.º 4
0
# Set of all numbers. Used in translate_math()
number_chars = set()
for value in numbers.values():
    number_chars.update(value)

# Set of all math symbols
all_math_symbols = set()
for value in math_symbols.values():
    all_math_symbols.update(value)

# Reverse all the bharati-braille-to-glyph mappings from mappings.py
# We need a glyph-to-bharati-braille mapping for each type of mapping
# This section converts all the characters common for all Indic scripts
cm_to_bb_punctuation = {}
for (braille, devanagari_list) in punctuation.items() | \
                                  paired_punctuation.items() | dashes.items():
    for each in devanagari_list:
        cm_to_bb_punctuation[each] = braille
cm_to_bb_numbers = {}
for (braille, devanagari_list) in numbers.items():
    for each in devanagari_list:
        cm_to_bb_numbers[each] = braille
cm_to_bb_math_punctuation = {}
for (braille, devanagari_list) in math_punctuation.items():
    for each in devanagari_list:
        cm_to_bb_math_punctuation[each] = braille

####################
#    BEGIN INDIC   #
#  PRE-PROCESSING  #
####################