Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
# main.py
|
|
|
|
|
|
|
| 2 |
|
| 3 |
from fastapi import FastAPI
|
| 4 |
-
from PIL import Image
|
| 5 |
-
import base64
|
| 6 |
from fastapi.responses import HTMLResponse, FileResponse
|
| 7 |
|
| 8 |
app = FastAPI()
|
|
@@ -30,24 +30,21 @@ async def root():
|
|
| 30 |
|
| 31 |
@app.get("/api")
|
| 32 |
async def cal_api():
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
#pilim = Image.open(image_path)
|
| 49 |
-
#pilimrot = pilim.rotate(45)
|
| 50 |
-
return {"data": images}
|
| 51 |
|
| 52 |
@app.get("/items/{item_id}")
|
| 53 |
async def read_item(item_id):
|
|
|
|
| 1 |
# main.py
|
| 2 |
+
from deepmultilingualpunctuation import PunctuationModel
|
| 3 |
+
import re
|
| 4 |
|
| 5 |
from fastapi import FastAPI
|
|
|
|
|
|
|
| 6 |
from fastapi.responses import HTMLResponse, FileResponse
|
| 7 |
|
| 8 |
app = FastAPI()
|
|
|
|
| 30 |
|
| 31 |
@app.get("/api")
|
| 32 |
async def cal_api():
|
| 33 |
+
|
| 34 |
+
input_text = "my name is clara i live in berkeley california"
|
| 35 |
+
|
| 36 |
+
model = PunctuationModel()
|
| 37 |
+
output_text = model.restore_punctuation(input_text)
|
| 38 |
+
|
| 39 |
+
split_text = output_text.split('. ')
|
| 40 |
+
pcnt_file_cr = '.\n'.join(split_text)
|
| 41 |
+
|
| 42 |
+
regex1 = r"\bi\b"
|
| 43 |
+
regex2 = r"(?<=[.?!;])\s*\w"
|
| 44 |
+
regex3 = r"^\w"
|
| 45 |
+
pcnt_file_cr_cap = re.sub(regex3, lambda x: x.group().upper(), re.sub(regex2, lambda x: x.group().upper(), re.sub(regex1, "I", pcnt_file_cr)))
|
| 46 |
+
|
| 47 |
+
return {"data": pcnt_file_cr_cap}
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
@app.get("/items/{item_id}")
|
| 50 |
async def read_item(item_id):
|