How to use the pycorrector.seq2seq_attention.data_reader.padding function in pycorrector

To help you get started, we’ve selected a few pycorrector examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shibing624 / pycorrector / pycorrector / seq2seq_attention / train.py View on Github external
def get_validation_data(input_texts, target_texts, vocab2id, maxlen=400):
    # 数据生成器
    X, Y = [], []
    for i in range(len(input_texts)):
        X.append(str2id(input_texts[i], vocab2id, maxlen))
        Y.append([vocab2id[GO_TOKEN]] + str2id(target_texts[i], vocab2id, maxlen) + [vocab2id[EOS_TOKEN]])
        X = np.array(padding(X, vocab2id))
        Y = np.array(padding(Y, vocab2id))
        return [X, Y], None
github shibing624 / pycorrector / pycorrector / seq2seq_attention / train.py View on Github external
def data_generator(input_texts, target_texts, vocab2id, batch_size, maxlen=400):
    # 数据生成器
    while True:
        X, Y = [], []
        for i in range(len(input_texts)):
            X.append(str2id(input_texts[i], vocab2id, maxlen))
            Y.append([vocab2id[GO_TOKEN]] + str2id(target_texts[i], vocab2id, maxlen) + [vocab2id[EOS_TOKEN]])
            if len(X) == batch_size:
                X = np.array(padding(X, vocab2id))
                Y = np.array(padding(Y, vocab2id))
                yield [X, Y], None
                X, Y = [], []
github shibing624 / pycorrector / pycorrector / seq2seq_attention / train.py View on Github external
def data_generator(input_texts, target_texts, vocab2id, batch_size, maxlen=400):
    # 数据生成器
    while True:
        X, Y = [], []
        for i in range(len(input_texts)):
            X.append(str2id(input_texts[i], vocab2id, maxlen))
            Y.append([vocab2id[GO_TOKEN]] + str2id(target_texts[i], vocab2id, maxlen) + [vocab2id[EOS_TOKEN]])
            if len(X) == batch_size:
                X = np.array(padding(X, vocab2id))
                Y = np.array(padding(Y, vocab2id))
                yield [X, Y], None
                X, Y = [], []
github shibing624 / pycorrector / pycorrector / seq2seq_attention / train.py View on Github external
def get_validation_data(input_texts, target_texts, vocab2id, maxlen=400):
    # 数据生成器
    X, Y = [], []
    for i in range(len(input_texts)):
        X.append(str2id(input_texts[i], vocab2id, maxlen))
        Y.append([vocab2id[GO_TOKEN]] + str2id(target_texts[i], vocab2id, maxlen) + [vocab2id[EOS_TOKEN]])
        X = np.array(padding(X, vocab2id))
        Y = np.array(padding(Y, vocab2id))
        return [X, Y], None