# Path: pypinyin/contrib/tone_convert.py



import re
from pypinyin.contrib.tone_convert import tone_to_tone2, tone2_to_tone

            Before a first, second or third tone syllable, 一 is pronounced with fourth tone.

                Examples：一天 (yī+tiān, "one day") becomes yìtiān [i˥˩tʰjɛn˥], 一年 (yī+nián, "one year") becomes yìnián [i˥˩njɛn˧˥], 一起 (yī+qǐ, "together") becomes yìqǐ [i˥˩t͡ɕʰi˨˩˦].

            When final, or when it comes at the end of a multi-syllable word (regardless of the first tone of the next word), 一 is pronounced with first tone. It also has first tone when used as an ordinal number (or part of one), and when it is immediately followed by any digit (including another 一; hence both syllables of the word 一一 yīyī and its compounds have first tone).
            When 一 is used between two reduplicated words, it may become neutral in tone (e.g. 看一看 kànyikàn ("to take a look of")).

        """  # noqa
        if '一' not in han:
            return pinyin_list

        tone2_pinyin_list = [tone_to_tone2(x[0]) for x in pinyin_list]
        changed = False

        for i, h in enumerate(han):
            current_pinyin = tone2_pinyin_list[i]
            if h == '一' and i < len(han) - 1:
                next_pinyin = tone2_pinyin_list[i + 1]
                if '4' in next_pinyin:
                    tone2_pinyin_list[i] = current_pinyin.replace('4', '2')
                    changed = True
                else:
                    tone2_pinyin_list[i] = _re_num.sub('4', current_pinyin)
                    changed = True
            elif h == '一':
                tone2_pinyin_list[i] = _re_num.sub('1', current_pinyin)
                changed = True

        if changed:

# Path: pypinyin/contrib/tone_convert.py



# Path: pypinyin/contrib/tone_sandhi.py
import re
from pypinyin.contrib.tone_convert import tone_to_tone2, tone2_to_tone


            Before a first, second or third tone syllable, 一 is pronounced with fourth tone.

                Examples：一天 (yī+tiān, "one day") becomes yìtiān [i˥˩tʰjɛn˥], 一年 (yī+nián, "one year") becomes yìnián [i˥˩njɛn˧˥], 一起 (yī+qǐ, "together") becomes yìqǐ [i˥˩t͡ɕʰi˨˩˦].

            When final, or when it comes at the end of a multi-syllable word (regardless of the first tone of the next word), 一 is pronounced with first tone. It also has first tone when used as an ordinal number (or part of one), and when it is immediately followed by any digit (including another 一; hence both syllables of the word 一一 yīyī and its compounds have first tone).
            When 一 is used between two reduplicated words, it may become neutral in tone (e.g. 看一看 kànyikàn ("to take a look of")).

        """  # noqa
        if '一' not in han:
            return pinyin_list

        tone2_pinyin_list = [tone_to_tone2(x[0]) for x in pinyin_list]
        changed = False

        for i, h in enumerate(han):
            current_pinyin = tone2_pinyin_list[i]
            if h == '一' and i < len(han) - 1:
                next_pinyin = tone2_pinyin_list[i + 1]
                if '4' in next_pinyin:
                    tone2_pinyin_list[i] = current_pinyin.replace('4', '2')
                    changed = True
                else:
                    tone2_pinyin_list[i] = _re_num.sub('4', current_pinyin)
                    changed = True
            elif h == '一':
                tone2_pinyin_list[i] = _re_num.sub('1', current_pinyin)
                changed = True

        if changed:

            return [[tone2_to_tone(x)] for x in tone2_pinyin_list]