Skip to content
Snippets Groups Projects
Commit 9e6931cd authored by Thomas Edwards's avatar Thomas Edwards
Browse files

Work towards USAS + ner

parent 20e3b60e
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,13 @@ def run_ner_on_text(page):
word = item.word
ner = item.ner
idx = item.idx
print(type(idx))
print(idx)
print(type(ner))
print(ner)
print(type(word))
print(word)
print('--------')
obj = {"word": word, "translation": "", "ner": ner, "idx": idx}
data.append(obj)
......
......@@ -11,10 +11,27 @@ def run_usas_on_text(page):
nlp.add_pipe('pymusas_rule_based_tagger', source=chinese_tagger_pipeline)
output_doc = nlp(page)
data = []
print(f'Text\tPOS\tUSAS Tags')
tags = []
print(f'Text\tPOS\tMWE start and end index\tUSAS Tags')
for token in output_doc:
print(f'{token.text}\t{token.pos_}\t{token._.pymusas_tags}')
start, end = token._.pymusas_mwe_indexes[0]
idx = (start, end)
for el in token._.pymusas_tags:
obj = {"word": token.text, "Usas Tags": el, "idx": idx}
tags.append(el)
data.append(obj)
res = []
procTags = []
for x in tags:
if x not in procTags:
res.append({"Tag": x, "Count": tags.count(x)})
procTags.append(x)
result = {'output': "Hello USAS", 'message': 'Done', 'code': 'SUCCESS'}
result = {'output': res, 'message': 'Done', 'code': 'SUCCESS'}
return result
......@@ -19,18 +19,22 @@ def test():
return "Success"
@app.route('/ner', methods=['POST'])
@app.route("/ner", methods=['POST'])
def ner():
request_data = request.get_json()
print(request_data)
#print(request_data)
page = request_data['page']
result = get_ner_for_data(page)
return result
@app.route("/usas")
@app.route("/usas", methods=['POST'])
def usas():
print('hello')
request_data = request.get_json()
print(request_data)
page = request_data['page']
result = get_usas_for_data(page)
return result
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment