-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
52 lines (43 loc) · 1.17 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
#Required Packages
import json
from flask import Flask, jsonify, request
import sys
#Handle Internal Packages
package_path = "./src/"
if package_path not in sys.path:
sys.path.append(package_path)
#Internal Package(s)
from utils import example
#Establish App
app = Flask(__name__)
#Functions
#Default
@app.route('/')
def index():
return jsonify({'name': 'Justin Gould',
'email': '[email protected]'})
#Combined Split and Tokenize
@app.route('/split_and_tokenize', methods=["POST"])
def split_and_tokenize():
#Run Function
p = request.get_json()
print(p, "\n", p["text"], "\n")
output = example.split_and_tokenize(p["text"])
print(output)
return jsonify({'output': output})
#Split Sentences
@app.route('/split_sentences', methods=["POST"])
def split_sentences():
#Run Function
p = request.get_json()
output = example.split_sentences(p["text"])
return jsonify({'output': output})
#Tokenize a Sentence
@app.route('/tokenize', methods=["POST"])
def tokenize():
#Run Function
p = request.get_json()
output = example.tokenize(p["sentence"])
return jsonify({'output': output})
#Run Application
app.run()