コード例 #1
0
ファイル: fullpinyintable.py プロジェクト: epico/libpinyin
def populate_more_zhuyin_index():
    for (zhuyin, flags) in zhuyin_index:
        correct = zhuyin
        # populate hsu zhuyin index
        matches = itertools.chain(handle_rules(zhuyin, hsu_correct),
                                  handle_special_rules(zhuyin, hsu_correct_special))
        for wrong in matches:
            newflags = '|'.join((flags, 'ZHUYIN_CORRECT_HSU'))
            hsu_zhuyin_index.append((wrong, newflags, correct))

        # populate eten26 zhuyin index
        matches = itertools.chain(handle_rules(zhuyin, eten26_correct),
                                  handle_special_rules(zhuyin, eten26_correct_special))
        for wrong in matches:
            newflags = '|'.join((flags, 'ZHUYIN_CORRECT_ETEN26'))
            eten26_zhuyin_index.append((wrong, newflags, correct))

    for (zhuyin, flags) in zhuyin_index:
        correct = zhuyin
        # remove duplicate items
        if zhuyin not in [x[0] for x in hsu_zhuyin_index]:
            hsu_zhuyin_index.append((zhuyin, flags, correct))

        if zhuyin not in [x[0] for x in eten26_zhuyin_index]:
            eten26_zhuyin_index.append((zhuyin, flags, correct))

    # populate shuffled zhuyin index
    for (zhuyin, flags) in zhuyin_index:
        correct = zhuyin
        shuffle_zhuyin_index.append((zhuyin, flags, correct))
        newflags = '|'.join((flags, 'ZHUYIN_CORRECT_SHUFFLE'))
        for shuffle in shuffle_all(zhuyin):
            assert shuffle not in [x[0] for x in shuffle_zhuyin_index]
            shuffle_zhuyin_index.append((shuffle, newflags, correct))
コード例 #2
0
def populate_more_bopomofo_index():
    for (bopomofo, flags) in bopomofo_index:
        correct = bopomofo
        # populate hsu bopomofo index
        matches = itertools.chain(handle_rules(bopomofo, hsu_correct),
                                  handle_special_rules(bopomofo, hsu_correct_special))
        for wrong in matches:
            newflags = '|'.join((flags, 'HSU_CORRECT'))
            hsu_bopomofo_index.append((wrong, newflags, correct))

        # populate eten26 bopomofo index
        matches = itertools.chain(handle_rules(bopomofo, eten26_correct),
                                  handle_special_rules(bopomofo, eten26_correct_special))
        for wrong in matches:
            newflags = '|'.join((flags, 'ETEN26_CORRECT'))
            eten26_bopomofo_index.append((wrong, newflags, correct))

    for (bopomofo, flags) in bopomofo_index:
        correct = bopomofo
        # remove duplicate items
        if bopomofo not in [x[0] for x in hsu_bopomofo_index]:
            hsu_bopomofo_index.append((bopomofo, flags, correct))

        if bopomofo not in [x[0] for x in eten26_bopomofo_index]:
            eten26_bopomofo_index.append((bopomofo, flags, correct))

    # populate shuffled bopomofo index
    for (bopomofo, flags) in bopomofo_index:
        correct = bopomofo
        shuffle_bopomofo_index.append((bopomofo, flags, correct))
        newflags = '|'.join((flags, 'SHUFFLE_CORRECT'))
        for shuffle in shuffle_all(bopomofo):
            assert shuffle not in [x[0] for x in shuffle_bopomofo_index]
            shuffle_bopomofo_index.append((shuffle, newflags, correct))
コード例 #3
0
def populate_more_zhuyin_index():
    for (zhuyin, flags) in zhuyin_index:
        correct = zhuyin
        # populate hsu zhuyin index
        matches = itertools.chain(
            handle_rules(zhuyin, hsu_correct),
            handle_special_rules(zhuyin, hsu_correct_special))
        for wrong in matches:
            newflags = '|'.join((flags, 'ZHUYIN_CORRECT_HSU'))
            hsu_zhuyin_index.append((wrong, newflags, correct))

        # populate eten26 zhuyin index
        matches = itertools.chain(
            handle_rules(zhuyin, eten26_correct),
            handle_special_rules(zhuyin, eten26_correct_special))
        for wrong in matches:
            newflags = '|'.join((flags, 'ZHUYIN_CORRECT_ETEN26'))
            eten26_zhuyin_index.append((wrong, newflags, correct))

    for (zhuyin, flags) in zhuyin_index:
        correct = zhuyin
        # remove duplicate items
        if zhuyin not in [x[0] for x in hsu_zhuyin_index]:
            hsu_zhuyin_index.append((zhuyin, flags, correct))

        if zhuyin not in [x[0] for x in eten26_zhuyin_index]:
            eten26_zhuyin_index.append((zhuyin, flags, correct))

    # populate shuffled zhuyin index
    for (zhuyin, flags) in zhuyin_index:
        correct = zhuyin
        shuffle_zhuyin_index.append((zhuyin, flags, correct))
        newflags = '|'.join((flags, 'ZHUYIN_CORRECT_SHUFFLE'))
        for shuffle in shuffle_all(zhuyin):
            assert shuffle not in [x[0] for x in shuffle_zhuyin_index]
            shuffle_zhuyin_index.append((shuffle, newflags, correct))