commit 251f1ba4e50954c2492ebd090e74f50a58e2d6c5 Author: Alexandra Date: Tue Aug 15 21:58:53 2023 -0700 wip_interface diff --git a/interface/__pycache__/app.cpython-38.pyc b/interface/__pycache__/app.cpython-38.pyc new file mode 100644 index 0000000..b9b9a4a Binary files /dev/null and b/interface/__pycache__/app.cpython-38.pyc differ diff --git a/interface/app.py b/interface/app.py new file mode 100644 index 0000000..e80b87d --- /dev/null +++ b/interface/app.py @@ -0,0 +1,52 @@ +import flask +from flask_navigation import Navigation + +UPLOAD_FOLDER = 'temp_uploads' +ALLOWED_EXTENSIONS = {'xml', 'flextext'} + +app = flask.Flask(__name__) +app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER +nav= Navigation(app) + +nav.Bar('top', [ + nav.Item('Convert Files', 'convert'), + nav.Item('About', 'about'), + nav.Item('Apertium for Language Technology', 'learn'), +]) + +def allowed_file(filename): + return '.' in filename and \ + filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS + +@app.route('/FLextoApertium', methods=['GET', 'POST']) +def convert(): + if flask.request.method == 'GET': + return flask.render_template("convert.html") + elif flask.request.method == 'POST': + #get data from response + form = flask.request.form + iso = form['iso'] + privacy = form['privacy'] + file = flask.request.files['files'] + if file.filename == '': + flash('No selected file') + return flask.redirect("convert.html") + if file and allowed_file(file.filename): + filename = flexfiles_%s(file.fil) %iso + file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) + #check apertium github for existing module based on iso code + #if privacy == "public": + #commit apertium module to apertium + #else: + #download the generated module as a zip file + return flask.render_template("access.html") + +@app.route('/FLextoApertium/access', methods=['GET', 'POST']) + +@app.route('/FLextoApertium/learn', methods=['GET', 'POST']) +def learn(): + return flask.render_template("learn.html") + +@app.route('/FLextoApertium/about', methods=['GET', 'POST']) +def about(): + return flask.render_template("about.html") \ No newline at end of file diff --git a/interface/static/my-style.css b/interface/static/my-style.css new file mode 100644 index 0000000..ddeebde --- /dev/null +++ b/interface/static/my-style.css @@ -0,0 +1,24 @@ +ul { + list-style-type: none; + margin: 0; + padding: 0; + overflow: hidden; + background-color: #333; +} + +li { + float: left; +} + +li a { + display: block; + color: white; + text-align: center; + padding: 14px 16px; + text-decoration: none; +} + +/* Change the link color to #111 (black) on hover */ +li a:hover { + background-color: #111; +} diff --git a/interface/templates/about.html b/interface/templates/about.html new file mode 100644 index 0000000..00ba21f --- /dev/null +++ b/interface/templates/about.html @@ -0,0 +1,23 @@ + + + About the project + + + + + +
+ +

FLex-to-Apertium Tools

+
+ +

About the project

+
+ + diff --git a/interface/templates/access.html b/interface/templates/access.html new file mode 100644 index 0000000..d96c373 --- /dev/null +++ b/interface/templates/access.html @@ -0,0 +1,28 @@ + + + Convert FLex files to Apertium Module + + + + + +
+ +

FLex-to-Apertium Tools

+ +

Access Generated Apertium Module

+

TODO Display generated repository option based on privacy selection

+

+ See the learn page for more information about how to use the generated + Apertium module and tips for improving the model. For insight on how the module is generated, see the + about page. +

+
+ + diff --git a/interface/templates/convert.html b/interface/templates/convert.html new file mode 100644 index 0000000..eb5b2df --- /dev/null +++ b/interface/templates/convert.html @@ -0,0 +1,43 @@ + + + Convert FLex files to Apertium Module + + + + + +
+ +

FLex-to-Apertium Tools

+ +

Convert FLex files to Apertium Module

+

+ Fill out the following information, upload XML or FLEXTEXT exports for one language, and select + submit to create an Apertium module for the language. Depending on the privacy settings selected, + the generated module will be available either as a link to a Github page or a download of the repository + as a zip file. +

+

+ See the learn page for more information about how to use the generated + Apertium module and tips for improving the model. For insight on how the module is generated, see the + about page. +

+

Enter iso code for the language:

+ +

Data confidentiality: + + + + +

+

Upload your XML and/or FLEXTEXT file(s):

+ +
+ + diff --git a/interface/templates/learn.html b/interface/templates/learn.html new file mode 100644 index 0000000..09281f8 --- /dev/null +++ b/interface/templates/learn.html @@ -0,0 +1,23 @@ + + + Using Apertium to Develop Language Technology + + + + + +
+ +

FLex-to-Apertium Tools

+
+ +

Apertium for language technology

+
+ +