Skip to content

Commit

Permalink
Improve naming of API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
janheinrichmerker committed Dec 17, 2020
1 parent 100d14c commit e1d21d8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 35 deletions.
50 changes: 35 additions & 15 deletions backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __call__(self, environ, start_response):
class ClassifyNewWD(Resource):
def post(self):
"""
Classifies input text to argument structure (Essays model, fasttext - big dataset)
Classifies input text to argument structure (WebD model, GloVe embeddings)
---
consumes:
- text/plain
Expand Down Expand Up @@ -132,7 +132,7 @@ def post(self):
class ClassifyNewPE(Resource):
def post(self):
"""
Classifies input text to argument structure (Essays model, fasttext embeddings)
Classifies input text to argument structure (Essays model, GloVe embeddings)
---
consumes:
Expand Down Expand Up @@ -165,7 +165,7 @@ def post(self):
class ClassifyES(Resource):
def post(self):
"""
Classifies input text to argument structure (Essays model, fasttext embeddings)
Classifies input text to argument structure (Essays model, fastText embeddings)
---
consumes:
- text/plain
Expand Down Expand Up @@ -197,7 +197,7 @@ def post(self):
class ClassifyWD(Resource):
def post(self):
"""
Classifies input text to argument structure (WebD model, fasttext - big dataset)
Classifies input text to argument structure (WebD model, fastText embeddings)
---
consumes:
- text/plain
Expand Down Expand Up @@ -229,7 +229,7 @@ def post(self):
class ClassifyES_dep(Resource):
def post(self):
"""
Classifies input text to argument structure (Essays model, dependency based)
Classifies input text to argument structure (Essays model, dependency-based embeddings)
---
consumes:
- text/plain
Expand Down Expand Up @@ -261,7 +261,7 @@ def post(self):
class ClassifyWD_dep(Resource):
def post(self):
"""
Classifies input text to argument structure (WebD model, dependency based)
Classifies input text to argument structure (WebD model, dependency-based embeddings)
---
consumes:
- text/plain
Expand Down Expand Up @@ -293,7 +293,7 @@ def post(self):
class ClassifyIBM(Resource):
def post(self):
"""
Classifies input text to argument structure (IBM model, fasttext - big dataset)
Classifies input text to argument structure (IBM model, fastText embeddings)
---
consumes:
- text/plain
Expand Down Expand Up @@ -325,7 +325,7 @@ def post(self):
class ClassifyCombo(Resource):
def post(self):
"""
Classifies input text to argument structure (Combo model - big dataset)
Classifies input text to argument structure (Combo model from <a href="https://github.com/uhh-lt/targer/blob/a2a89ebfb366bc723a38dae963f8cb8b130f7e81/backend/backend.py#L305">Universität Hamburg</a>)
---
consumes:
- text/plain
Expand Down Expand Up @@ -354,14 +354,34 @@ def post(self):
return response


api.add_resource(ClassifyES, '/classifyES')
api.add_resource(ClassifyWD, '/classifyWD')
api.add_resource(ClassifyES_dep, '/classifyES_dep')
api.add_resource(ClassifyWD_dep, '/classifyWD_dep')
api.add_resource(ClassifyIBM, '/classifyIBM')
class DeprecatedResource(Resource):
def __init__(self, resource: Resource):
self.resource = resource

def post(self):
"""
Deprecated.
---
deprecated: true
"""
return self.resource.post()


api.add_resource(ClassifyIBM, '/classifyIBMfasttext')
api.add_resource(ClassifyES_dep, '/classifyPEdep')
api.add_resource(ClassifyES, '/classifyPEfasttext')
api.add_resource(ClassifyNewPE, '/classifyPEglove')
api.add_resource(ClassifyWD_dep, '/classifyWDdep')
api.add_resource(ClassifyWD, '/classifyWDfasttext')
api.add_resource(ClassifyNewWD, '/classifyWDglove')
api.add_resource(ClassifyCombo, '/classifyCombo')
api.add_resource(ClassifyNewPE, '/classifyNewPE')
api.add_resource(ClassifyNewWD, '/classifyNewWD')
api.add_resource(DeprecatedResource(ClassifyIBM), '/classifyIBM')
api.add_resource(DeprecatedResource(ClassifyES_dep), '/classifyES_dep')
api.add_resource(DeprecatedResource(ClassifyES), '/classifyES')
api.add_resource(DeprecatedResource(ClassifyNewPE), '/classifyNewPE')
api.add_resource(DeprecatedResource(ClassifyWD_dep), '/classifyWD_dep')
api.add_resource(DeprecatedResource(ClassifyWD), '/classifyWD')
api.add_resource(DeprecatedResource(ClassifyNewWD), '/classifyNewWD')

app.jinja_env.auto_reload = True
app.config['TEMPLATES_AUTO_RELOAD'] = True
Expand Down
26 changes: 13 additions & 13 deletions frontend/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ def create_api_url(endpoint):
class Sender:
def send(self, text, classifier):

if classifier == "WD":
url = create_api_url("classifyWD")
elif classifier == "WD_dep":
url = create_api_url("classifyWD_dep")
elif classifier == "ES":
url = create_api_url("classifyES")
if classifier == "IBM":
url = create_api_url("classifyIBMfasttext")
elif classifier == "ES_dep":
url = create_api_url("classifyES_dep")
elif classifier == "IBM":
url = create_api_url("classifyIBM")
elif classifier == "Combo":
url = create_api_url("classifyCombo")
url = create_api_url("classifyPEdep")
elif classifier == "ES":
url = create_api_url("classifyPEfasttext")
elif classifier == "NEWPE":
url = create_api_url("classifyNewPE")
url = create_api_url("classifyPEglove")
elif classifier == "WD_dep":
url = create_api_url("classifyWDdep")
elif classifier == "WD":
url = create_api_url("classifyWDfasttext")
elif classifier == "NEWWD":
url = create_api_url("classifyNewWD")
url = create_api_url("classifyWDglove")
elif classifier == "Combo":
url = create_api_url("classifyCombo")

try:
r = requests.post(url, data=text.encode("utf-8"))
Expand Down
14 changes: 7 additions & 7 deletions frontend/templates/template_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ <h5 class="card-title">Argument Tagger</h5>
<div class="form-row">
<label for="model">Model to label with</label>
<select class="form-control" id="model">
<option value="ES">Essays (fastText)</option>
<option value="ES_dep">Essays (Dependency)</option>
<option value="NEWPE">Essays (Glove)</option>
<option value="WD">WebDiscourse (fastText)</option>
<option value="WD_dep">WebDiscourse (Dependency)</option>
<option value="NEWWD">WebDiscourse (Glove)</option>
<option value="IBM" selected="selected">IBM (fastText)</option>
<option value="IBM" selected="selected">IBM (fastText embeddings)</option>
<option value="ES_dep">Essays (dependency-based embeddings)</option>
<option value="ES">Essays (fastText embeddings)</option>
<option value="NEWPE">Essays (GloVe embeddings)</option>
<option value="WD_dep">WebDiscourse (dependency-based embeddings)</option>
<option value="WD">WebDiscourse (fastText embeddings)</option>
<option value="NEWWD">WebDiscourse (GloVe embeddings)</option>
<option value="Combo">Combo</option>
</select>
</div>
Expand Down

0 comments on commit e1d21d8

Please sign in to comment.