diff --git a/sloleks_accentuation2_tab2xml.py b/sloleks_accentuation2_tab2xml.py index 4011f19..d2bf890 100644 --- a/sloleks_accentuation2_tab2xml.py +++ b/sloleks_accentuation2_tab2xml.py @@ -134,7 +134,7 @@ with open("data/new_sloleks/final_sloleks.xml", "ab") as myfile: new_element = etree.Element('feat') new_element.attrib['att'] = 'SAMPA' - new_element.attrib['val'] = result = convert_to_SAMPA(accentuated_word) + new_element.attrib['val'] = convert_to_SAMPA(accentuated_word) wf.append(new_element) word_glob_num += 1 diff --git a/text2SAMPA.py b/text2SAMPA.py index 136b0db..895b559 100644 --- a/text2SAMPA.py +++ b/text2SAMPA.py @@ -157,7 +157,7 @@ def convert_to_SAMPA(word): next_letter_i = 1 if word[0] == '\"': letter_i = 1 - if word[2] == ':': + if len(word) > 2 and word[2] == ':': if len(word) > 3: next_letter_i = 3 else: @@ -167,7 +167,10 @@ def convert_to_SAMPA(word): # word[next_letter_i] = 'n\'' return ''.join(word) else: - next_letter_i = 2 + if len(word) > 2: + next_letter_i = 2 + else: + return ''.join(word) elif len(word) > 1 and word[1] == '\"': next_letter_i = 2 # {('m', 'f'): 'F'}