Esempio n. 1
0
def prepare_training_data(sent_pairs):
    voc = Vocabulary()
    sent_pairs_normalized = []
    for sent_p in sent_pairs:
        # normalize incorrect and correct sentence in pair, and append them to normalized sentence pairs
        incorrect_sent_normalized = normalize_string(sent_p[0])
        correct_sent_normalized = normalize_string(sent_p[1])

        normalized_sents_pair = (
            incorrect_sent_normalized, correct_sent_normalized)
        sent_pairs_normalized.append(normalized_sents_pair)
        # add normalized sentence pair to vocabulary
        voc.add_sentence_pair(normalized_sents_pair)

    return voc, sent_pairs_normalized