Updated to new STARK version + some small updates
This commit is contained in:
@@ -112,6 +112,7 @@ def create_app():
|
||||
'Number of nodes': gettext('Number of nodes'),
|
||||
'Head node': gettext('Head node'),
|
||||
'Grew-match URL': gettext('Grew-match URL'),
|
||||
'Ratio': gettext('Ratio'),
|
||||
'%DIFF': gettext('%DIFF'),
|
||||
'OR': gettext('OR'),
|
||||
'BIC': gettext('BIC'),
|
||||
@@ -162,9 +163,15 @@ def create_app():
|
||||
translations = _translations[get_locale()]
|
||||
if request.method == 'POST':
|
||||
form = request.form
|
||||
configs = {}
|
||||
configs = {
|
||||
'greedy_counter': 'yes',
|
||||
'input_path': '',
|
||||
'tree_size': '1-1000000',
|
||||
'display_size': '1-1000000',
|
||||
'complete_tree_type': True,
|
||||
'ignored_labels': []
|
||||
}
|
||||
# mandatory parameters
|
||||
configs['input_path'] = ''
|
||||
validation = {}
|
||||
|
||||
|
||||
@@ -194,29 +201,10 @@ def create_app():
|
||||
validation['file'] = gettext('Please insert either input url or provide a file.')
|
||||
validation['input_url'] = gettext('Please insert either input url or provide a file.')
|
||||
|
||||
tree_size_min = None
|
||||
if 'tree_size_min' in form:
|
||||
tree_size_min = form['tree_size_min']
|
||||
|
||||
tree_size_max = None
|
||||
if 'tree_size_max' in form:
|
||||
tree_size_max = form['tree_size_max']
|
||||
|
||||
def validate_tree_size(tree_size_min, tree_size_max):
|
||||
if tree_size_min is None or tree_size_max is None:
|
||||
validation['tree_size'] = gettext('Please provide information about minimum and maximum tree size.')
|
||||
return False
|
||||
|
||||
if int(tree_size_min) > int(tree_size_max):
|
||||
validation['tree_size'] = gettext('Tree size minimum should be smaller than tree size maximum.')
|
||||
return False
|
||||
return True
|
||||
|
||||
if validate_tree_size(tree_size_min, tree_size_max):
|
||||
configs['tree_size'] = f'{tree_size_min}-{tree_size_max}' if tree_size_min != tree_size_max else f'{tree_size_min}'
|
||||
if 'display_size' in form and form['display_size']:
|
||||
configs['display_size'] = form['display_size']
|
||||
|
||||
def validate_node_type(node_type):
|
||||
# TODO EXPAND NODE TYPE
|
||||
node_type_options = {'upos', 'form', 'lemma', 'upos', 'xpos', 'feats', 'deprel'}
|
||||
if len(node_type) == 0:
|
||||
validation['node_type'] = gettext('Please select at least one node type.')
|
||||
@@ -230,6 +218,7 @@ def create_app():
|
||||
return True
|
||||
|
||||
node_type = []
|
||||
|
||||
if 'node_type_upos' in form:
|
||||
node_type.append('upos')
|
||||
if 'node_type_form' in form:
|
||||
@@ -237,7 +226,9 @@ def create_app():
|
||||
if 'node_type_lemma' in form:
|
||||
node_type.append('lemma')
|
||||
|
||||
if validate_node_type(node_type):
|
||||
if 'node_type_none' in form:
|
||||
configs['node_type'] = None
|
||||
elif validate_node_type(node_type):
|
||||
configs['node_type'] = '+'.join(node_type)
|
||||
|
||||
# mandatory parameters with default value
|
||||
@@ -246,8 +237,6 @@ def create_app():
|
||||
# TODO depends on computer
|
||||
configs['cpu_cores'] = 12
|
||||
|
||||
# TODO FINALIZE THIS!
|
||||
configs['complete_tree_type'] = True
|
||||
configs['dependency_type'] = 'labeled_trees' in form and form['labeled_trees'] == 'on'
|
||||
configs['node_order'] = 'fixed_order' in form and form['fixed_order'] == 'on'
|
||||
configs['association_measures'] = 'association_measures' in form and form['association_measures'] == 'on'
|
||||
@@ -257,9 +246,13 @@ def create_app():
|
||||
if 'root_restriction' in form and form['root_restriction']:
|
||||
configs['root_whitelist'] = form['root_restriction'].split('|')
|
||||
|
||||
if 'ignored_labels' in form and form['ignored_labels']:
|
||||
configs['ignored_labels'] = form['ignored_labels'].split('|')
|
||||
|
||||
if 'query' in form and form['query']:
|
||||
configs['query'] = form['query']
|
||||
configs['tree_size'] = '0'
|
||||
configs['display_size'] = '0'
|
||||
else:
|
||||
configs['query'] = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user