-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
29 lines (23 loc) · 770 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from flask import Flask, render_template, request
import spacy
from spacy import lang
from spacy.lang.lb import Luxembourgish
from tabulate import tabulate
app = Flask(__name__)
# Create the nlp object
nlp = Luxembourgish()
nlp = spacy.load("./lux-tagger-July2023/model-best/")
@app.route('/')
def index():
return render_template('index.html')
@app.route('/pos_tag', methods=['POST'])
def pos_tag():
text = request.form['text']
doc = nlp(text)
headers = ["Text", "Part-of-Speech", "Stopword", "Shape", "Alpha"]
rows = []
for token in doc:
rows.append([token.text, token.tag_, token.is_stop, token.shape_, token.is_alpha])
return tabulate(rows, headers=headers, tablefmt='html')
if __name__ == '__main__':
app.run(debug=True)