Added new updates acording to log.
This commit is contained in:
parent
0735ba4f5a
commit
42a3f773a9
23
app.py
23
app.py
|
@ -8,6 +8,7 @@ import time
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from flask import Flask, render_template, request, send_file, redirect, url_for
|
from flask import Flask, render_template, request, send_file, redirect, url_for
|
||||||
|
from flask_headers import headers
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
from stark import run
|
from stark import run
|
||||||
|
|
||||||
|
@ -134,6 +135,7 @@ def create_app():
|
||||||
return render_template('result.html', head_row=displayed_head, content=displayed_content_dict)
|
return render_template('result.html', head_row=displayed_head, content=displayed_content_dict)
|
||||||
|
|
||||||
@app.route('/', methods=['GET', 'POST'])
|
@app.route('/', methods=['GET', 'POST'])
|
||||||
|
# @headers({'Cache-Control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'})
|
||||||
def index():
|
def index():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = request.form
|
form = request.form
|
||||||
|
@ -240,6 +242,14 @@ def create_app():
|
||||||
configs['detailed_results_file'] = None
|
configs['detailed_results_file'] = None
|
||||||
|
|
||||||
configs['frequency_threshold'] = 0
|
configs['frequency_threshold'] = 0
|
||||||
|
if 'frequency_threshold' in form and form['frequency_threshold']:
|
||||||
|
try:
|
||||||
|
int(form['frequency_threshold'])
|
||||||
|
except ValueError:
|
||||||
|
validation['frequency_threshold'] = f'Please insert an Integer.'
|
||||||
|
else:
|
||||||
|
configs['frequency_threshold'] = int(form['frequency_threshold'])
|
||||||
|
|
||||||
configs['lines_threshold'] = None
|
configs['lines_threshold'] = None
|
||||||
|
|
||||||
configs['continuation_processing'] = False
|
configs['continuation_processing'] = False
|
||||||
|
@ -256,14 +266,23 @@ def create_app():
|
||||||
name = ''.join(random.choices(string.ascii_uppercase + string.digits, k=60))
|
name = ''.join(random.choices(string.ascii_uppercase + string.digits, k=60))
|
||||||
configs['output'] = os.path.join('media', name)
|
configs['output'] = os.path.join('media', name)
|
||||||
if len(validation) > 0:
|
if len(validation) > 0:
|
||||||
|
a = request.args.get('noreload')
|
||||||
|
b = request.args
|
||||||
|
c = request
|
||||||
return render_template('index.html', validation=validation)
|
return render_template('index.html', validation=validation)
|
||||||
try:
|
try:
|
||||||
run(configs)
|
run(configs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
validation['general'] = 'Processing failed! Please recheck your settings.'
|
validation['general'] = 'Processing failed! Please recheck your settings, e.g. input format or head node description.'
|
||||||
if len(validation) > 0:
|
if len(validation) > 0:
|
||||||
return render_template('index.html', validation=validation)
|
return render_template('index.html', validation=validation)
|
||||||
return redirect(url_for('result', result_id=name))
|
# check if there are no results
|
||||||
|
with open(os.path.join('media', name), 'r') as rf:
|
||||||
|
content = list(csv.reader(rf, delimiter='\t'))
|
||||||
|
if len(content) == 1:
|
||||||
|
validation['results'] = False
|
||||||
|
return render_template('index.html', validation=validation)
|
||||||
|
return redirect(url_for('result', result_id=name, order_by='Frequency ', order_type='desc'))
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
|
@ -55,11 +55,11 @@ label {
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
table-layout: fixed;
|
table-layout: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
th {
|
th {
|
||||||
width: 300px;
|
max-width: 300px;
|
||||||
padding: 10px 0 10px;
|
padding: 10px 0 10px;
|
||||||
background-color: #cccccc;
|
background-color: #cccccc;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -69,7 +69,7 @@ th {
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
width: 300px;
|
max-width: 300px;
|
||||||
padding: 10px 0 10px;
|
padding: 10px 0 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-right: solid 1px #bbbbbb;
|
border-right: solid 1px #bbbbbb;
|
||||||
|
@ -81,7 +81,7 @@ td {
|
||||||
color: #F44336;
|
color: #F44336;
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 18px;
|
min-height: 18px;
|
||||||
font-size: 12px;
|
font-size: 1.1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (min-width: 993px) {
|
@media only screen and (min-width: 993px) {
|
||||||
|
@ -89,3 +89,24 @@ td {
|
||||||
width: 60%;
|
width: 60%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-field .helper-text {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-field > label:not(.label-icon).active {
|
||||||
|
-webkit-transform: translateY(-14px);
|
||||||
|
transform: translateY(-14px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-field .file-path-wrapper {
|
||||||
|
height: 75px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#advanced-tree-expand {
|
||||||
|
color: rgba(0, 0, 0, 0.87);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wider-container {
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Global array to store input names
|
// Global array to store input names
|
||||||
var globalInputList = ['tree_size_min', 'tree_size_max', 'file', 'association_measures', 'labeled_trees', 'node_type_upos', 'fixed_order', 'input_url', 'node_type_lemma', 'root_restriction', 'node_type_form'];
|
var globalInputList = ['tree_size_min', 'tree_size_max', 'file', 'association_measures', 'labeled_trees', 'node_type_upos', 'fixed_order', 'input_url', 'node_type_lemma', 'root_restriction', 'node_type_form', 'frequency_threshold'];
|
||||||
|
//const URLSearchParams = window.URLSearchParams;
|
||||||
// Function to store values to local storage
|
// Function to store values to local storage
|
||||||
function storeValuesToLocalstorage() {
|
function storeValuesToLocalstorage() {
|
||||||
globalInputList.forEach(function(inputName) {
|
globalInputList.forEach(function(inputName) {
|
||||||
|
@ -30,6 +30,9 @@ function readValuesFromLocalstorage() {
|
||||||
// set label to active
|
// set label to active
|
||||||
$("label[for='" + inputElement.attr('id') + "']").addClass('active');
|
$("label[for='" + inputElement.attr('id') + "']").addClass('active');
|
||||||
}
|
}
|
||||||
|
if (inputName === 'frequency_threshold' && text_val === null) {
|
||||||
|
text_val = '1'
|
||||||
|
}
|
||||||
inputElement.val(text_val);
|
inputElement.val(text_val);
|
||||||
|
|
||||||
} else if (inputType === 'checkbox') {
|
} else if (inputType === 'checkbox') {
|
||||||
|
@ -50,7 +53,7 @@ function readValuesFromLocalstorage() {
|
||||||
document.addEventListener("DOMContentLoaded", function(event) {
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
tree_size = readValuesFromLocalstorage()
|
tree_size = readValuesFromLocalstorage()
|
||||||
|
|
||||||
var valuesForSlider = [2,3,4,5];
|
var valuesForSlider = [1,2,3,4,5];
|
||||||
|
|
||||||
var format = {
|
var format = {
|
||||||
to: function(value) {
|
to: function(value) {
|
||||||
|
@ -72,6 +75,40 @@ document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
},
|
},
|
||||||
format: format
|
format: format
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
|
// OLD VERSION
|
||||||
|
var perfEntries = performance.getEntriesByType("navigation");
|
||||||
|
|
||||||
|
for (var i = 0; i < perfEntries.length; i++) {
|
||||||
|
if (perfEntries[i].type === 'back_forward') {
|
||||||
|
window.location.href = '?noreload=true'
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var urlParams = new URLSearchParams(window.location.search);
|
||||||
|
if (!urlParams.has('noreload')) {
|
||||||
|
if (Object.keys(localStorage).length > 1) {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = '?noreload=true'
|
||||||
|
}
|
||||||
|
|
||||||
|
}*/
|
||||||
|
var perfEntries = performance.getEntriesByType("navigation");
|
||||||
|
for (var i = 0; i < perfEntries.length; i++) {
|
||||||
|
if (perfEntries[i].type === 'back_forward') {
|
||||||
|
window.location.href = '/'
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var urlParams = new URLSearchParams(window.location.search);
|
||||||
|
if (urlParams.has('reload')) {
|
||||||
|
// if (Object.keys(localStorage).length > 1) {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = '/'
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
(function($){
|
(function($){
|
||||||
|
@ -81,6 +118,10 @@ document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
|
||||||
}); // end of document ready
|
}); // end of document ready
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
$('.modal').modal();
|
||||||
|
// var instance = M.Modal.getInstance(elem);
|
||||||
|
// instance.open();
|
||||||
|
|
||||||
$('.input-field input[type="checkbox"]').on('change', function() {
|
$('.input-field input[type="checkbox"]').on('change', function() {
|
||||||
var isChecked = $('.input-field input[type="checkbox"]:checked').length > 0;
|
var isChecked = $('.input-field input[type="checkbox"]:checked').length > 0;
|
||||||
$('#node-type-error').hide();
|
$('#node-type-error').hide();
|
||||||
|
|
|
@ -21,7 +21,7 @@ $(document).ready(function() {
|
||||||
$(".table-wrapper tbody tr").click(function() {
|
$(".table-wrapper tbody tr").click(function() {
|
||||||
var url = $(this).data("href");
|
var url = $(this).data("href");
|
||||||
if (url) {
|
if (url) {
|
||||||
window.location.href = url;
|
window.open(url, '_blank');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$(".th-desc").hide();
|
$(".th-desc").hide();
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="grey darken-2" role="navigation">
|
<nav class="grey darken-2" role="navigation">
|
||||||
<div class="nav-wrapper container"><a id="logo-container" href="/" class="brand-logo">STARK</a>
|
<div class="nav-wrapper container"><a id="logo-container" href="/?reload=true" class="brand-logo">STARK</a>
|
||||||
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
||||||
<li><a href="/about">About</a></li>
|
<li><a href="/about">About</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="grey darken-2" role="navigation">
|
<nav class="grey darken-2" role="navigation">
|
||||||
<div class="nav-wrapper container"><a id="logo-container" href="/" class="brand-logo">STARK</a>
|
<div class="nav-wrapper container"><a id="logo-container" href="/?reload=true" class="brand-logo">STARK</a>
|
||||||
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
||||||
<li><a href="/about">About</a></li>
|
<li><a href="/about">About</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -24,11 +24,11 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<p class="caption">Welcome to the online demo interface for STARK - a highly-customizible tool designed to extract various types of syntactic trees from dependency-parsed corpora (treebanks). Unlike the original command-line version, this user-friendly interface offers a streamlined set of settings, which are described in more detail here. Simply upload your treebank and click ‘SUBMIT’ to view the initial results!</p>
|
<p class="caption">Welcome to the online demo interface for STARK - a highly-customizible tool designed to extract various types of syntactic trees from dependency-parsed corpora (treebanks). Unlike the original command-line version, this user-friendly interface offers a streamlined set of settings, which are described in more detail here. Simply upload your treebank and click ‘SUBMIT’ to view the initial results!</p>
|
||||||
<form action="{{ url_for('index') }}" method="POST" enctype="multipart/form-data" id="submit-form">
|
<form autocomplete="off" action="{{ url_for('index') }}" method="POST" enctype="multipart/form-data" id="submit-form">
|
||||||
<h4>Input data</h4>
|
<h4>Input data</h4>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<label><b>Upload a treebank</b> in CONLL-U format</label>
|
<label><b>Upload a treebank</b> in CONLL-U format (<a class="nav-link" href="https://github.com/clarinsi/STARK/blob/master/settings.md#--input" title="Help"><span class="menu-title sr-only">Help</span></a>)</label>
|
||||||
<div class = "file-field input-field">
|
<div class = "file-field input-field">
|
||||||
<div class = "btn">
|
<div class = "btn">
|
||||||
<span>Browse</span>
|
<span>Browse</span>
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
<input id="input_url" name="input_url" type="text" class="validate{% if 'input_url' in validation %} invalid{% endif %}">
|
<input id="input_url" name="input_url" type="text" class="validate{% if 'input_url' in validation %} invalid{% endif %}">
|
||||||
<label for="input_url"><u>Or</u> insert a URL link to a treebank in CONLL-U format</label>
|
<label for="input_url"><u>Or</u> insert a URL link to a treebank in CONLL-U format (<a class="nav-link" href="https://raw.githubusercontent.com/UniversalDependencies/UD_English-GUM/master/en_gum-ud-train.conllu" title="Example"><span class="menu-title sr-only">Example</span></a>)</label>
|
||||||
{% if 'input_url' in validation %}
|
{% if 'input_url' in validation %}
|
||||||
<span class="helper-text" data-error="{{validation['input_url']}}"></span>
|
<span class="helper-text" data-error="{{validation['input_url']}}"></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -99,7 +99,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<h4><a class="waves-effect waves-light inline" id="advanced-tree-expand"><i class="material-icons">add</i></a> Advanced settings</h4>
|
<h4><a class="waves-effect waves-light inline" id="advanced-tree-expand"><i class="material-icons">add</i> Advanced settings</a></h4>
|
||||||
<div class="card" id="advanced-tree">
|
<div class="card" id="advanced-tree">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -133,16 +133,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="input-field col s12">
|
|
||||||
<input id="root_restriction" name="root_restriction" type="text" class="validate">
|
|
||||||
<label for="root_restriction"><b>Head</b>: specify potential restrictions on the head node (<a class="nav-link" href="https://github.com/clarinsi/STARK/blob/master/settings.md#--head" title="Help"><span class="menu-title sr-only">Help</span></a>)</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<label><b>Association measures</b>: print MI, MI3, Dice, logDice, t-score and simple-LL scores (<a class="nav-link" href="https://github.com/clarinsi/STARK/blob/master/settings.md#--association_measures" title="Help"><span class="menu-title sr-only">Help</span></a>)</label>
|
<label><b>Association measures</b>: print MI, logDice and t-score (<a class="nav-link" href="https://github.com/clarinsi/STARK/blob/master/settings.md#--association_measures" title="Help"><span class="menu-title sr-only">Help</span></a>)</label>
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<div class="switch">
|
<div class="switch">
|
||||||
<label>
|
<label>
|
||||||
|
@ -155,6 +148,23 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="input-field col s12">
|
||||||
|
<input id="frequency_threshold" name="frequency_threshold" type="text" class="validate {% if 'frequency_threshold' in validation %} invalid{% endif %}" value="1">
|
||||||
|
<label for="frequency_threshold"><b>Frequency threshold</b>: specify the minimum frequency of a tree in the treebank (<a class="nav-link" href="https://github.com/clarinsi/STARK/blob/master/settings.md#--frequency_threshold" title="Help"><span class="menu-title sr-only">Help</span></a>)</label>
|
||||||
|
{% if 'frequency_threshold' in validation %}
|
||||||
|
<span class="helper-text" data-error="{{validation['frequency_threshold']}}"></span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="input-field col s12">
|
||||||
|
<input id="root_restriction" name="root_restriction" type="text" class="validate">
|
||||||
|
<label for="root_restriction"><b>Head</b>: specify potential restrictions on the head node (<a class="nav-link" href="https://github.com/clarinsi/STARK/blob/master/settings.md#--head" title="Help"><span class="menu-title sr-only">Help</span></a>)</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if 'general' in validation %}
|
{% if 'general' in validation %}
|
||||||
|
@ -167,6 +177,17 @@
|
||||||
<i class="material-icons right">send</i>
|
<i class="material-icons right">send</i>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<!-- Modal Structure -->
|
||||||
|
<div id="modal1" class="modal">
|
||||||
|
<div class="modal-content">
|
||||||
|
<h4>No results</h4>
|
||||||
|
<p>Processing with your settings didn't produce any results!</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Ok</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -197,5 +218,20 @@
|
||||||
<script src="static/js/nouislider.min.js"></script>
|
<script src="static/js/nouislider.min.js"></script>
|
||||||
<script src="static/js/init.js"></script>
|
<script src="static/js/init.js"></script>
|
||||||
|
|
||||||
|
{% if 'results' in validation %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function($){
|
||||||
|
$(function(){
|
||||||
|
|
||||||
|
$('.sidenav').sidenav();
|
||||||
|
|
||||||
|
}); // end of document ready
|
||||||
|
$(document).ready(function(){
|
||||||
|
$('.modal').modal('open');
|
||||||
|
});
|
||||||
|
})(jQuery); // end of jQuery name space
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -13,13 +13,13 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="grey darken-2" role="navigation">
|
<nav class="grey darken-2" role="navigation">
|
||||||
<div class="nav-wrapper container"><a id="logo-container" href="/" class="brand-logo">STARK</a>
|
<div class="nav-wrapper container"><a id="logo-container" href="/?reload=true" class="brand-logo">STARK</a>
|
||||||
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
||||||
<li><a href="/about">About</a></li>
|
<li><a href="/about">About</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="container">
|
<div class="container wider-container">
|
||||||
<br>
|
<br>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for i in range(content['Tree']|length) %}
|
{% for i in range(content['Tree']|length) %}
|
||||||
<tr {% if 'Grew-match URL' in content %} class="tr-link" data-href={{ content['Grew-match URL'][i] }} {% endif %}>
|
<tr {% if 'Grew-match URL' in content %} class="tr-link" data-toggle="tooltip" title="See examples in Grew-match" data-href={{ content['Grew-match URL'][i] }} {% endif %}>
|
||||||
{% for col in content %}
|
{% for col in content %}
|
||||||
{% if not col == 'Grew-match URL' %}
|
{% if not col == 'Grew-match URL' %}
|
||||||
<td>{{ content[col][i] }}</td>
|
<td>{{ content[col][i] }}</td>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user