-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (26 loc) · 999 Bytes
/
main.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
from fastapi import FastAPI
from typing import Optional, List, Dict
from pydantic import BaseModel
from ML.Extractive.textrank import extractive_textrank
from ML.Extractive.luhn import extractive_luhn
from ML.Extractive.lsa import extractive_lsa
from ML.Extractive.lexrank import extractive_lexrank
app = FastAPI()
class Text(BaseModel):
text: str
len: int
@app.get("/")
def home():
return {"hello"}
@app.post("/summarize/extractive/textrank")
def summarize_textrank(text: Text):
return {"text_summary": extractive_textrank(text.text, text.len) }
@app.post("/summarize/extractive/lexrank")
def summarize_lexrank(text: Text):
return {"text_summary": extractive_lexrank(text.text, text.len) }
@app.post("/summarize/extractive/luhn")
def summarize_luhn(text: Text):
return {"text_summary": extractive_luhn(text.text, text.len) }
@app.post("/summarize/extractive/lsa")
def summarize_lsa(text: Text):
return {"text_summary": extractive_lsa(text.text, text.len) }