-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
113 lines (84 loc) · 2.92 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
from flask import Flask, render_template
import os.path
from flask_pie import PieController
from pie_extended.models.lasla import imports as lasla_get
from pie_extended.models.fro import imports as fro_get
from pie_extended.models.fr import imports as fr_get
from pie_extended.models.freem import imports as freem_get
from pie_extended.models.grc import imports as grc_get
from pie_extended.models.dum import imports as dum_get
from pie_extended.cli.sub import get_tagger
here = os.path.dirname(os.path.abspath(__file__))
app = Flask(__name__, static_folder=os.path.join(here, "statics"), template_folder=os.path.join(here, "templates"))
# Add the lemmatizer routes
controller_lasla = PieController(
path="/api/lasla/", name="lasla-api",
tagger=get_tagger("lasla", batch_size=8, device="cpu"),
headers={"X-Accel-Buffering": "no"},
get_iterator_and_processor=lasla_get.get_iterator_and_processor,
force_lower=False
)
controller_lasla.init_app(app)
controller_fro = PieController(
path="/api/fro-1/", name="fro-api",
tagger=get_tagger("fro", batch_size=8, device="cpu"),
headers={"X-Accel-Buffering": "no"},
get_iterator_and_processor=fro_get.get_iterator_and_processor,
force_lower=False
)
controller_fro.init_app(app)
controller_fr = PieController(
path="/api/fr/", name="fr-api",
tagger=get_tagger("fr", batch_size=8, device="cpu"),
headers={"X-Accel-Buffering": "no"},
get_iterator_and_processor=fr_get.get_iterator_and_processor,
force_lower=False
)
controller_fr.init_app(app)
controller_freem = PieController(
path="/api/freem/", name="freem-api",
tagger=get_tagger("freem", batch_size=8, device="cpu"),
headers={"X-Accel-Buffering": "no"},
get_iterator_and_processor=freem_get.get_iterator_and_processor,
force_lower=False
)
controller_freem.init_app(app)
controller_grc = PieController(
path="/api/grc/", name="grc-api",
tagger=get_tagger("grc", batch_size=8, device="cpu"),
headers={"X-Accel-Buffering": "no"},
get_iterator_and_processor=grc_get.get_iterator_and_processor,
force_lower=False
)
controller_grc.init_app(app)
controller_dum = PieController(
path="/api/dum/", name="dum-api",
tagger=get_tagger("dum", batch_size=8, device="cpu"),
headers={"X-Accel-Buffering": "no"},
get_iterator_and_processor=dum_get.get_iterator_and_processor,
force_lower=False
)
controller_dum.init_app(app)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/latin")
def latin():
return render_template("lasla.html")
@app.route("/fro")
def fro():
return render_template("fro.html")
@app.route("/grc")
def grc():
return render_template("grc.html")
@app.route("/fr")
def fr():
return render_template("fr.html")
@app.route("/freem")
def freem():
return render_template("freem.html")
@app.route("/dum")
def dum():
return render_template("dum.html")
if __name__ == "__main__":
app.run(debug=True)