def main(): data_set = SquADDataSet(data_path='./data/SQuAD/train-v1.1.json') print('size: ', data_set.size()) for index in range(20): context, question, answer = data_set.get_data(index) print('#' + str(index) + ' context:', context) print('#' + str(index) + ' question:', question) print('#' + str(index) + ' answer:', answer) print('++++++++++++++++++++++++++++++++++++++++++++++++++++')
def main(): qa = Seq2SeqV2QA() qa.load_model(model_dir_path='./models') data_set = SquADDataSet(data_path='./data/SQuAD/train-v1.1.json') for i in range(20): index = i * 10 paragraph, question, actual_answer = data_set.get_data(index) predicted_answer = qa.reply(paragraph, question) print('context: ', paragraph) print('question: ', question) print({'guessed_answer': predicted_answer, 'actual_answer': actual_answer})
def main(): with open('./data/SQuAD/train-v1.1.json') as file: ds = json.load(file) data_set = SquADDataSet(queries=ds) # data_set = SquADDataSet(data_path='./data/SQuAD/train-v1.1.json') print('size: ', data_set.size()) for index, value in enumerate(data_set.get_data()[0:1]): context, question, answer = value print('#' + str(index) + ' context:', context) print('#' + str(index) + ' question:', question) print('#' + str(index) + ' answer:', answer) print('++++++++++++++++++++++++++++++++++++++++++++++++++++')
def main(): qa = Seq2SeqQA() qa.load_model(model_dir_path='./models') data_set = SquADDataSet(data_path='./data/SQuAD/train-v1.1.json') with open('./data/SQuAD/train-v1.1.json') as f: import json print(json.load(f)['data'][0]['paragraphs'][0]['qas'])
def main(): random_state = 42 output_dir_path = './models' np.random.seed(random_state) data_set = SquADDataSet(data_path='./data/SQuAD/train-v1.1.json') qa = Seq2SeqQA() batch_size = 64 epochs = 200 history = qa.fit(data_set, model_dir_path=output_dir_path, batch_size=batch_size, epochs=epochs, random_state=random_state)
from flask import Flask, request, redirect, render_template, flash, abort, jsonify from keras_question_and_answering_system.library.seq2seq import Seq2SeqQA from keras_question_and_answering_system.library.utility.squad import SquADDataSet app = Flask(__name__) app.config.from_object(__name__) # load config from this file , flaskr.py # Load default config and override config from an environment variable app.config.from_envvar('FLASKR_SETTINGS', silent=True) app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 seq2seq = Seq2SeqQA() data_set = SquADDataSet(data_path=None) qa_list = list() @app.route('/') def home(): return render_template('home.html', qa_list=qa_list) #@app.route('/about') #def about(): # return 'About Us' @app.route('/qa', methods=['POST', 'GET']) def qa(): if request.method == 'POST': if 'question_context' not in request.form and 'question' not in request.form: flash('No sentence post')