def evaluate(test_data_path,
             test_label_path,
             model_path,
             output_path,
             pad_index=0,
             max_length=256):
    test_data = dp.create_data(test_data_path)
    test_data = keras.preprocessing.sequence.pad_sequences(test_data,
                                                           value=pad_index,
                                                           padding="post",
                                                           maxlen=max_length)
    test_labl = dp.create_label(test_label_path)
    model = keras.models.load_model(model_path)

    result = model.evaluate(test_data, test_labl)
    with open(output_path, 'w+', encoding='UTF-8') as f:
        f.write(str(result[1]))
    f.close()
def predict(test_data_path,
            model_path,
            output_path,
            pad_index=0,
            max_length=256):
    test_data = dp.create_data(test_data_path)
    test_data = keras.preprocessing.sequence.pad_sequences(test_data,
                                                           value=pad_index,
                                                           padding="post",
                                                           maxlen=max_length)

    model = keras.models.load_model(model_path)

    results = model.predict(test_data)
    with open(output_path, 'w+', encoding='UTF-8') as f:
        for result in results:
            f.write("{}\n".format(result))
        f.close()
import sys

train_data_path = sys.argv[1]
train_label_path = sys.argv[2]

dev_data_path = sys.argv[3]
dev_label_path = sys.argv[4]

model_path = sys.argv[5]

#dict_path="dict.txt"

pad_index = 0
max_length = 256

train_data = dp.create_data(train_data_path)
train_label = dp.create_label(train_label_path)

dev_data = dp.create_data(dev_data_path)
dev_label = dp.create_label(dev_label_path)

#word_index_dict=dp.create_dict(dict_path)
#index_word_dict=dict([(value, key) for (key,value) in word_index_dict.items()])

vocab_size = 50000

train_data = keras.preprocessing.sequence.pad_sequences(train_data,
                                                        value=pad_index,
                                                        padding='post',
                                                        maxlen=max_length)
dev_data = keras.preprocessing.sequence.pad_sequences(dev_data,