Пример #1
0
def main():
    data = DataStorage()
    while True:
        possible_questions = get_words(data)
        data.save()
        p_random = 0.5
        if random.random() < p_random:
            random_int = random.randint(0, len(possible_questions) - 1)
        else:
            random_int = 0
        score, question, answer = possible_questions[random_int]
        clear()
        attempt = input('Type {}: '.format(question))
        data.answer(question, attempt == answer)
        if attempt == answer:
            print('Correct!')
        else:
            print('Incorrect!')
            chords = None
            if question[-1] == '-':
                raise Exception('Unimplemented')
                #keys = ortho_keys.chord_to_keys(answer.upper(), None, None)
            elif question[0] == '-':
                raise Exception('Unimplemented')
                #keys = ortho_keys.chord_to_keys(None, None, answer.upper())
            else:
                chords = ortho_matching.match_text(answer.upper())
            if not chords:
                raise Exception('Could not match text {}'.format(
                    answer.upper()))
            for chord in chords:
                keys = ortho_keys.chord_to_keys(chord['start'], chord['vowel'],
                                                chord['end'])
                vchord = visualize.visualize_keys(keys)
                print(vchord)
            while attempt != answer:
                attempt = input('Type {}: '.format(question))
                if attempt == answer:
                    print('Correct!')
                else:
                    print('Incorrect!')
Пример #2
0
        vowel = gd["vowel"]
        remainder = gd["remainder"]
    else:
        remainder = text
    return start, vowel, remainder


def match_end(text, pattern):
    match = pattern.match(text)
    end = None
    if match:
        gd = match.groupdict()
        end = gd["end"]
        remainder = gd["remainder"]
    else:
        remainder = text
    return end, remainder


if __name__ == "__main__":
    while True:
        text = raw_input("Enter text:")
        chords = match_text(text)
        if chords is None:
            print("Cannot encode word")
        else:
            for chord in chords:
                keys = ortho_keys.chord_to_keys(chord["start"], chord["vowel"], chord["end"])
                vchord = visualize.visualize_keys(keys)
                print(vchord)
Пример #3
0
        vowel = gd['vowel']
        remainder = gd['remainder']
    else:
        remainder = text
    return start, vowel, remainder

def match_end(text, pattern):
    match = pattern.match(text)
    end = None
    if match:
        gd = match.groupdict()
        end = gd['end']
        remainder = gd['remainder']
    else:
        remainder = text
    return end, remainder


if __name__ == '__main__':
    while True:
        text = raw_input('Enter text:')
        chords = match_text(text)
        if chords is None:
            print('Cannot encode word')
        else:
            for chord in chords:
                keys = ortho_keys.chord_to_keys(chord['start'], chord['vowel'], chord['end'])
                vchord = visualize.visualize_keys(keys)
                print(vchord)