|
|
@ -1,4 +1,5 @@
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
|
|
|
|
import logging
|
|
|
|
from flask import Flask, send_from_directory, redirect, jsonify, request
|
|
|
|
from flask import Flask, send_from_directory, redirect, jsonify, request
|
|
|
|
import pandas as pd
|
|
|
|
import pandas as pd
|
|
|
|
from sqlite3 import Error
|
|
|
|
from sqlite3 import Error
|
|
|
@ -19,6 +20,8 @@ app = Flask(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
app.config.from_json('config.json')
|
|
|
|
app.config.from_json('config.json')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Digisam:
|
|
|
|
class Digisam:
|
|
|
|
|
|
|
|
|
|
|
@ -31,13 +34,15 @@ class Digisam:
|
|
|
|
@staticmethod
|
|
|
|
@staticmethod
|
|
|
|
def create_connection(db_file):
|
|
|
|
def create_connection(db_file):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
logger.debug('Connection to database: {}'.format(db_file))
|
|
|
|
|
|
|
|
|
|
|
|
conn = sqlite3.connect(db_file, check_same_thread=False)
|
|
|
|
conn = sqlite3.connect(db_file, check_same_thread=False)
|
|
|
|
|
|
|
|
|
|
|
|
conn.execute('pragma journal_mode=wal')
|
|
|
|
conn.execute('pragma journal_mode=wal')
|
|
|
|
|
|
|
|
|
|
|
|
return conn
|
|
|
|
return conn
|
|
|
|
except Error as e:
|
|
|
|
except Error as e:
|
|
|
|
print(e)
|
|
|
|
logger.error(e)
|
|
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
@ -292,7 +297,9 @@ def ner(model_id):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
assert "".join([pred['word'] for pred in output_sentence]) == "".join(input_sentence).replace(" ", "")
|
|
|
|
assert "".join([pred['word'] for pred in output_sentence]) == "".join(input_sentence).replace(" ", "")
|
|
|
|
except AssertionError:
|
|
|
|
except AssertionError:
|
|
|
|
import ipdb;ipdb.set_trace()
|
|
|
|
logger.warning('Input and output different!!! \n\n\nInput: {}\n\nOutput: {}\n'.
|
|
|
|
|
|
|
|
format("".join(input_sentence).replace(" ", ""),
|
|
|
|
|
|
|
|
"".join([pred['word'] for pred in output_sentence])))
|
|
|
|
|
|
|
|
|
|
|
|
return jsonify(output)
|
|
|
|
return jsonify(output)
|
|
|
|
|
|
|
|
|
|
|
|