Skip to content
Snippets Groups Projects
Commit ffe49ee0 authored by Simon Will's avatar Simon Will
Browse files

Fall back to other model when lin is ungrammatical

parent d403f78c
No related branches found
No related tags found
No related merge requests found
MODELS = [
'n3epsilon.noise.plusv2_web2to1_ratio05_exp.yaml',
'n3epsilon.noise.plusv2_exp.yaml',
'n3epsilon.noise.plusv2_exp235.yaml',
'n3epsilon.noise.plusv2_exp5510.yaml',
'n3epsilon.noise.plusv2_exp5515.yaml',
'n3epsilon.noise.plusv2_exp5515_onereset.yaml',
'n3epsilon.noise.plusv2_exp5515_max10.yaml',
'n3epsilon.noise.plusv2_web2to1_ratio05.yaml',
]
CURRENT_MODEL = 'n3epsilon.noise.plusv2_web2to1_ratio05_exp.yaml'
CURRENT_MODEL = 'n3epsilon.noise.plusv2_exp5515_max10.yaml'
FALLBACK_MODEL = 'n3epsilon.noise.plusv2_web2to1_ratio05.yaml'
JOEY_SERVER_URL = 'http://localhost:5051/'
......@@ -18,4 +18,5 @@ MODELS = [
'n3epsilon.noise.plusv2_web2to1_ratio05_prod.yaml',
]
CURRENT_MODEL = 'n3epsilon.noise.plusv2_web2to1_ratio05_prod.yaml'
FALLBACK_MODEL = 'n3epsilon.noise.plusv2.yaml'
......@@ -56,6 +56,18 @@ class ParseResult(Result):
mrl = functionalise(lin)
if not mrl:
error = 'Parsed linear query is ungrammatical'
current_app.logger.warning(error)
# Try fallback model
fallback_model = current_app.config.get('FALLBACK_MODEL')
if fallback_model:
current_app.logger.info(
'Using fallback model {}'.format(fallback_model))
fallback_parse_result = cls.from_nl(nl, model=fallback_model)
if fallback_parse_result.success:
current_app.logger.info('Fallback successful')
return fallback_parse_result
# Fallback model was unsuccessful, as well.
return cls(False, nl, lin, mrl, model=model, error=error)
return cls(True, nl, lin, mrl, model=model)
......
......@@ -84,11 +84,8 @@ def create_feedback():
if current_user.is_authenticated:
feedback['user_id'] = current_user.id
if data.get('model'):
feedback['model'] = data['model']
else:
feedback['train_model'] = current_app.config['CURRENT_MODEL']
feedback['model'] = ''
feedback['train_model'] = current_app.config['CURRENT_MODEL']
feedback['model'] = data.get('model', '')
# TODO: Do these things in form.
nl = data['nl'].strip()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment