From 349b8042d1cef1993fc27f1a48b9e8c92b7b8d45 Mon Sep 17 00:00:00 2001 From: lkrsnik Date: Wed, 6 Mar 2024 09:40:12 +0100 Subject: [PATCH] Multiple visual adaptations. --- app.py | 71 ++++--- messages.pot | 223 ++++++++++++++------- requirements.txt | 2 +- static/css/style.css | 20 +- static/js/init.js | 2 +- templates/about.html | 65 +----- templates/base.html | 252 ++---------------------- templates/index.html | 86 +------- templates/result.html | 129 +++++------- translations/en/LC_MESSAGES/messages.mo | Bin 2802 -> 2990 bytes translations/en/LC_MESSAGES/messages.po | 247 +++++++++++++++-------- translations/sl/LC_MESSAGES/messages.mo | Bin 2829 -> 2797 bytes translations/sl/LC_MESSAGES/messages.po | 240 ++++++++++++++-------- 13 files changed, 614 insertions(+), 723 deletions(-) diff --git a/app.py b/app.py index 96558da..d010270 100755 --- a/app.py +++ b/app.py @@ -15,40 +15,12 @@ from stark import run UPLOAD_FOLDER = 'uploads' ALLOWED_EXTENSIONS = {'conllu'} DAYS_BEFORE_DELETION = 1 -TABLE_COLUMNS2DISPLAYED_TABLE_COLUMNS = { - 'Tree': 'Tree', - 'Absolute frequency': 'Frequency', - 'Number of nodes': 'Number of nodes', - 'Head node': 'Head node', - 'Grew-match URL': 'Grew-match URL', - 'Order': 'Order', - 'MI': 'MI', - 'logDice': 'logDice', - 't-score': 't-score' -} -DISPLAYED_TABLE_COLUMNS2TABLE_COLUMNS = {v: k for k, v in TABLE_COLUMNS2DISPLAYED_TABLE_COLUMNS.items()} DEFAULT_LANGUAGE = 'en' LANGUAGES = ['en', 'sl'] _translations = { - 'en': { - 'hello': 'Hello', - 'welcome': 'Welcome', - 'greeting': 'How are you?', - 'name': 'Your name:', - 'code': 'en', - 'switch_code': 'SL', - 'switch_link': '?lang=sl', - }, - 'sl': { - 'hello': 'Hola', - 'welcome': 'Bienvenido', - 'greeting': '¿Cómo estás?', - 'name': 'Tu nombre:', - 'code': 'sl', - 'switch_code': 'EN', - 'switch_link': '?lang=en', - }, + 'en': {}, + 'sl': {}, } @@ -115,6 +87,7 @@ def create_app(): @app.route('/stark/result/', methods=['GET', 'POST']) def result(result_id): + if request.method == 'POST': for filename in os.listdir('media'): file_path = os.path.join('media', filename) @@ -125,14 +98,37 @@ def create_app(): os.remove(file_path) return send_file(os.path.join('media', result_id), as_attachment=True, download_name='results.tsv') - order_by_display = request.args.get('order_by') - order_by = DISPLAYED_TABLE_COLUMNS2TABLE_COLUMNS[order_by_display[:-1]] if order_by_display is not None else None - order_type = request.args.get('order_type') + with open(os.path.join('media', result_id), 'r') as rf: content = list(csv.reader(rf, delimiter='\t')) head = content[0] content_dict = {h: [] for h in head} + table_columns2displayed_table_columns = { + 'Tree': gettext('Tree'), + 'Absolute frequency': gettext('Frequency'), + 'Number of nodes': gettext('Number of nodes'), + 'Head node': gettext('Head node'), + 'Grew-match URL': gettext('Grew-match URL'), + 'Order': gettext('Order'), + 'MI': gettext('MI'), + 'logDice': gettext('logDice'), + 't-score': gettext('t-score') + } + if 'Absolute frequency in second treebank' in head: + table_columns2displayed_table_columns['Absolute frequency'] = gettext('Frequency in A') + table_columns2displayed_table_columns['Absolute frequency in second treebank'] = gettext('Frequency in B') + if 'MI' in table_columns2displayed_table_columns: + del table_columns2displayed_table_columns['MI'] + if 'logDice' in table_columns2displayed_table_columns: + del table_columns2displayed_table_columns['logDice'] + if 't-score' in table_columns2displayed_table_columns: + del table_columns2displayed_table_columns['t-score'] + displayed_table_columns2table_columns = {v: k for k, v in table_columns2displayed_table_columns.items()} + order_by_display = request.args.get('order_by') + order_by = displayed_table_columns2table_columns[ + order_by_display[:-1]] if order_by_display is not None else None + order_type = request.args.get('order_type') if order_by is not None and order_by in head: sort_id = head.index(order_by) if order_type == 'asc': @@ -147,11 +143,11 @@ def create_app(): for j, v in enumerate(row): content_dict[head[j]].append(v) - displayed_head = [TABLE_COLUMNS2DISPLAYED_TABLE_COLUMNS[col] for col in head if col in TABLE_COLUMNS2DISPLAYED_TABLE_COLUMNS] + displayed_head = [table_columns2displayed_table_columns[col] for col in head if col in table_columns2displayed_table_columns] displayed_content_dict = {} for column, v in content_dict.items(): - if column in TABLE_COLUMNS2DISPLAYED_TABLE_COLUMNS: - displayed_content_dict[TABLE_COLUMNS2DISPLAYED_TABLE_COLUMNS[column]] = v + if column in table_columns2displayed_table_columns: + displayed_content_dict[table_columns2displayed_table_columns[column]] = v return render_template('result.html', head_row=displayed_head, content=displayed_content_dict) @app.route('/stark/', methods=['GET', 'POST']) @@ -328,7 +324,8 @@ def create_app(): if len(content) == 1: validation['results'] = False return render_template('index.html', validation=validation, translations=translations) - return redirect(url_for('result', result_id=name, order_by='Frequency ', order_type='desc', lang=gettext('code'))) + order_by = gettext('Frequency ') if not configs['compare'] else gettext('Frequency in A ') + return redirect(url_for('result', result_id=name, order_by=order_by, order_type='desc', lang=gettext('code'))) return render_template('index.html', translations=translations) return app diff --git a/messages.pot b/messages.pot index cfd42a7..56de7bc 100644 --- a/messages.pot +++ b/messages.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-02-20 10:56+0100\n" +"POT-Creation-Date: 2024-03-06 09:29+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,227 +17,312 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.14.0\n" -#: app.py:192 app.py:193 +#: app.py:108 +msgid "Tree" +msgstr "" + +#: app.py:109 +msgid "Frequency" +msgstr "" + +#: app.py:110 +msgid "Number of nodes" +msgstr "" + +#: app.py:111 +msgid "Head node" +msgstr "" + +#: app.py:112 +msgid "Grew-match URL" +msgstr "" + +#: app.py:113 +msgid "Order" +msgstr "" + +#: app.py:114 +msgid "MI" +msgstr "" + +#: app.py:115 +msgid "logDice" +msgstr "" + +#: app.py:116 +msgid "t-score" +msgstr "" + +#: app.py:119 +msgid "Frequency in A" +msgstr "" + +#: app.py:120 +msgid "Frequency in B" +msgstr "" + +#: app.py:175 app.py:176 msgid "Please insert either input url or file, not both of them." msgstr "" -#: app.py:203 app.py:297 +#: app.py:186 app.py:281 msgid "Incorrect URL!" msgstr "" -#: app.py:205 app.py:206 +#: app.py:188 app.py:189 msgid "Please insert either input url or provide a file." msgstr "" -#: app.py:218 +#: app.py:201 msgid "Please provide information about minimum and maximum tree size." msgstr "" -#: app.py:222 +#: app.py:205 msgid "Tree size minimum should be smaller than tree size maximum." msgstr "" -#: app.py:233 +#: app.py:216 msgid "Please select at least one node type." msgstr "" -#: app.py:238 +#: app.py:221 msgid "Node option" msgstr "" -#: app.py:238 +#: app.py:221 msgid "is not supported. Please enter valid options." msgstr "" -#: app.py:286 app.py:287 +#: app.py:269 app.py:270 msgid "Please insert either compare url or file, not both of them." msgstr "" -#: app.py:307 +#: app.py:293 msgid "Please insert an Integer." msgstr "" -#: app.py:331 +#: app.py:318 msgid "" "Processing failed! Please recheck your settings, e.g. input format or " "head node description." msgstr "" -#: app.py:340 templates/about.html:18 templates/about.html:20 -#: templates/index.html:18 templates/index.html:20 templates/index.html:32 -#: templates/result.html:18 templates/result.html:20 +#: app.py:327 +msgid "Frequency " +msgstr "" + +#: app.py:327 +msgid "Frequency in A " +msgstr "" + +#: app.py:328 templates/base.html:20 templates/base.html:22 +#: templates/index.html:8 templates/result.html:15 msgid "code" msgstr "" -#: templates/about.html:20 templates/about.html:31 templates/index.html:20 -#: templates/result.html:20 +#: templates/about.html:7 templates/base.html:22 msgid "About" msgstr "" -#: templates/about.html:21 templates/index.html:21 templates/result.html:21 +#: templates/about.html:10 +msgid "intro_description" +msgstr "" + +#: templates/base.html:23 msgid "switch_link" msgstr "" -#: templates/about.html:22 templates/index.html:22 templates/result.html:22 +#: templates/base.html:24 msgid "switch_code" msgstr "" -#: templates/about.html:32 -msgid "about_description" +#: templates/base.html:43 +msgid "Issuer" msgstr "" -#: templates/index.html:31 -msgid "intro_description" +#: templates/base.html:47 +msgid "Financial support" msgstr "" -#: templates/index.html:33 +#: templates/base.html:51 +msgid "Transfer tool" +msgstr "" + +#: templates/base.html:55 +msgid "License" +msgstr "" + +#: templates/base.html:59 +msgid "Support" +msgstr "" + +#: templates/index.html:9 msgid "Input data" msgstr "" -#: templates/index.html:36 +#: templates/index.html:12 templates/index.html:20 msgid "Upload a treebank" msgstr "" -#: templates/index.html:36 templates/index.html:180 +#: templates/index.html:12 templates/index.html:20 templates/index.html:160 +#: templates/index.html:167 msgid "in CONLL-U format" msgstr "" -#: templates/index.html:36 templates/index.html:64 templates/index.html:72 -#: templates/index.html:112 templates/index.html:127 templates/index.html:143 -#: templates/index.html:160 templates/index.html:170 templates/index.html:176 -#: templates/index.html:180 +#: templates/index.html:12 templates/index.html:41 templates/index.html:49 +#: templates/index.html:89 templates/index.html:104 templates/index.html:120 +#: templates/index.html:126 templates/index.html:132 templates/index.html:140 +#: templates/index.html:159 templates/index.html:160 msgid "Help" msgstr "" -#: templates/index.html:39 templates/index.html:183 +#: templates/index.html:15 templates/index.html:163 msgid "Browse" msgstr "" -#: templates/index.html:43 templates/index.html:187 +#: templates/index.html:19 msgid "Upload" msgstr "" -#: templates/index.html:52 templates/index.html:197 +#: templates/index.html:29 templates/index.html:177 msgid "Or" msgstr "" -#: templates/index.html:52 templates/index.html:197 +#: templates/index.html:29 templates/index.html:177 msgid "insert a URL link to a treebank in CONLL-U format" msgstr "" -#: templates/index.html:52 templates/index.html:197 +#: templates/index.html:29 templates/index.html:177 msgid "Example" msgstr "" -#: templates/index.html:61 +#: templates/index.html:38 msgid "Tree specification" msgstr "" -#: templates/index.html:64 +#: templates/index.html:41 msgid "Tree size" msgstr "" -#: templates/index.html:64 +#: templates/index.html:41 msgid "number of tokens in the tree" msgstr "" -#: templates/index.html:72 +#: templates/index.html:49 msgid "Node type" msgstr "" -#: templates/index.html:72 +#: templates/index.html:49 msgid "token characteristics to consider" msgstr "" -#: templates/index.html:78 +#: templates/index.html:55 msgid "Part-of-speech" msgstr "" -#: templates/index.html:87 +#: templates/index.html:64 msgid "Lemma" msgstr "" -#: templates/index.html:93 +#: templates/index.html:70 msgid "Form" msgstr "" -#: templates/index.html:107 +#: templates/index.html:84 msgid "Advanced settings" msgstr "" -#: templates/index.html:112 +#: templates/index.html:89 msgid "Labeled trees" msgstr "" -#: templates/index.html:112 +#: templates/index.html:89 msgid "include names of dependency relations" msgstr "" -#: templates/index.html:116 templates/index.html:131 templates/index.html:147 +#: templates/index.html:93 templates/index.html:108 templates/index.html:144 msgid "No" msgstr "" -#: templates/index.html:119 templates/index.html:134 templates/index.html:150 +#: templates/index.html:96 templates/index.html:111 templates/index.html:147 msgid "Yes" msgstr "" -#: templates/index.html:127 +#: templates/index.html:104 msgid "Fixed order" msgstr "" -#: templates/index.html:127 +#: templates/index.html:104 msgid "differentiate trees based on surface word order" msgstr "" -#: templates/index.html:143 -msgid "Association measures" +#: templates/index.html:120 +msgid "Head" msgstr "" -#: templates/index.html:143 -msgid "print MI, logDice and t-score" +#: templates/index.html:120 +msgid "specify potential restrictions on the head node" +msgstr "" + +#: templates/index.html:126 +msgid "Query" +msgstr "" + +#: templates/index.html:126 +msgid "write a query. Note: Tree size attribute will be ignored!" msgstr "" -#: templates/index.html:160 +#: templates/index.html:132 msgid "Frequency threshold" msgstr "" -#: templates/index.html:160 +#: templates/index.html:132 msgid "specify the minimum frequency of a tree in the treebank" msgstr "" -#: templates/index.html:170 -msgid "Head" +#: templates/index.html:140 +msgid "Association measures" msgstr "" -#: templates/index.html:170 -msgid "specify potential restrictions on the head node" +#: templates/index.html:140 +msgid "print MI, logDice and t-score" msgstr "" -#: templates/index.html:176 -msgid "Query" +#: templates/index.html:155 +msgid "Compare treebanks" msgstr "" -#: templates/index.html:176 -msgid "write a query. Note: Tree size attribute will be ignored!" +#: templates/index.html:159 +msgid "" +"Select a reference treebank to identify key phenomena (prints the " +"%DIFF, BIC and OR keyness scores)." msgstr "" -#: templates/index.html:180 +#: templates/index.html:160 templates/index.html:167 msgid "Upload a compare corpus" msgstr "" -#: templates/index.html:211 +#: templates/index.html:191 msgid "Submit" msgstr "" -#: templates/index.html:219 +#: templates/index.html:199 msgid "No results" msgstr "" -#: templates/index.html:220 +#: templates/index.html:200 msgid "Processing with your settings didnt produce any results!" msgstr "" -#: templates/result.html:32 +#: templates/result.html:8 +msgid "Results" +msgstr "" + +#: templates/result.html:15 +msgid "Back to chosen settings" +msgstr "" + +#: templates/result.html:16 msgid "Download complete results" msgstr "" diff --git a/requirements.txt b/requirements.txt index c89782f..04e1df4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ Flask==3.0.0 requests==2.31.0 flask-babel==4.0.0 -stark @ git+https://github.com/clarinsi/STARK@eff0c8609c9acc2bc0b096339e91e71430cbf762 +stark @ git+https://github.com/clarinsi/STARK@master diff --git a/static/css/style.css b/static/css/style.css index c371a86..233765c 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -271,12 +271,15 @@ h5 { } .page-footer { + bottom: 0; /* Position footer at the bottom */ + width: 100%; + height: 500px; padding-top: 0px; } .footer-element { width: 100%; - height: 300px; + height: 320px; border-radius: 2px; } @@ -293,3 +296,18 @@ h5 { .em-1 { font-size: 1em; } + +html, body { + min-height: 100vh; + margin: 0; + display: flex; + flex-direction: column; +} + +.content { + min-height: 100vh; +} + +footer { + margin-top: auto; +} diff --git a/static/js/init.js b/static/js/init.js index bc21a42..d487952 100644 --- a/static/js/init.js +++ b/static/js/init.js @@ -1,5 +1,5 @@ // 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', 'frequency_threshold']; +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', 'query', 'compare_url', 'compare_file']; // Function to store values to local storage function storeValuesToLocalstorage() { diff --git a/templates/about.html b/templates/about.html index 7db157b..0eefac9 100644 --- a/templates/about.html +++ b/templates/about.html @@ -1,62 +1,17 @@ - - - - - - STARK - - - - - - - - - - - +{% extends "base.html" %} +{% block content %}

-

{{ _('About') }}

-

{{ _('intro_description') }}

+
{{ _('About') }}
+
+
+ {{ _('intro_description') }} +
+
-
- -
-
-
-
-
Credits
-

Add some logos here?

-
-
-
- -
- - - - - - - - - - - +{% endblock %} +{% block custom_js %}{% endblock %} diff --git a/templates/base.html b/templates/base.html index cce92ee..c819776 100644 --- a/templates/base.html +++ b/templates/base.html @@ -9,11 +9,11 @@ - - - + + + - +