-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (25 loc) · 753 Bytes
/
app.py
File metadata and controls
29 lines (25 loc) · 753 Bytes
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 crypt import methods
from distutils.log import debug
from operator import methodcaller
from flask import Flask, render_template, request
from rake_nltk import Rake
# Flask constructor takes the name of
# current module (__name__) as argument.
app = Flask(__name__)
@app.route('/', methods=['POST'])
def rake_extractor():
"""
Uses Rake to extract the top 5 keywords from a text
Arguments: text (str)
Returns: list of keywords (list)
"""
print(request.method)
text = request.form['text']
r = Rake()
r.extract_keywords_from_text(text)
return_dict= {}
return_dict['keywords'] = r.get_ranked_phrases()[:5]
return return_dict
# main driver function
if __name__ == '__main__':
app.run(debug=True)