Skip to content

Commit

Permalink
Merge pull request #94 from sb7-winners/tkDocker
Browse files Browse the repository at this point in the history
tk - init commit
  • Loading branch information
dmmiller612 authored Jan 18, 2021
2 parents 91dc75d + baf814b commit 170eb90
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions requirements-service.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ tqdm==4.32.2
neuralcoref==4.0
argparse
scikit-learn
bert-extractive-summarizer==0.4.2
bert-extractive-summarizer==0.6.1
Flask
flask-cors
nltk
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz
26 changes: 23 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ def convert_to_paragraphs(self) -> str:
sentences: List[str] = self.run()
return ' '.join([sentence.strip() for sentence in sentences]).strip()

@app.route('/', methods=['GET'])
def hello_world():
return 'Hello, World!'

@app.route('/summarize', methods=['POST'])
def convert_raw_text():
@app.route('/summarize_by_ratio', methods=['POST'])
def convert_raw_text_by_ratio():
ratio = float(request.args.get('ratio', 0.2))
min_length = int(request.args.get('min_length', 25))
max_length = int(request.args.get('max_length', 500))
Expand All @@ -69,6 +72,23 @@ def convert_raw_text():
'summary': summary
})

@app.route('/summarize_by_sentence', methods=['POST'])
def convert_raw_text_by_sent():
num_sentences = int(request.args.get('num_sentences', 5))
min_length = int(request.args.get('min_length', 25))
max_length = int(request.args.get('max_length', 500))

data = request.data
if not data:
abort(make_response(jsonify(message="Request must have raw text"), 400))

parsed = Parser(data).convert_to_paragraphs()
summary = summarizer(parsed, num_sentences=num_sentences, min_length=min_length, max_length=max_length)

return jsonify({
'summary': summary
})


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='')
Expand All @@ -81,7 +101,7 @@ def convert_raw_text():
parser.add_argument('-greediness', dest='greediness', help='', default=0.45)
parser.add_argument('-reduce', dest='reduce', help='', default='mean')
parser.add_argument('-hidden', dest='hidden', help='', default=-2)
parser.add_argument('-port', dest='port', help='', default=5000)
parser.add_argument('-port', dest='port', help='', default=8080)
parser.add_argument('-host', dest='host', help='', default='0.0.0.0')

args = parser.parse_args()
Expand Down

0 comments on commit 170eb90

Please sign in to comment.