File size: 601 Bytes
0891faf
 
b8d2b35
 
 
0891faf
 
 
 
b8d2b35
0891faf
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from fastapi import FastAPI, Query
from wtpsplit import SaT

app = FastAPI()

# Load the model once during startup
# 'sat-3l-sm' is fast and efficient for CPU Spaces
model = SaT("sat-3l-sm")

@app.get("/")
def home():
    return {"message": "SaT Segmentation API is running. Use /segment?text=your_text_here"}

@app.get("/segment")
def segment_text(text: str = Query(..., description="The text you want to split into sentences")):
    # Perform the segmentation
    sentences = model.split(text)
    return {
        "input": text,
        "sentences": sentences,
        "count": len(sentences)
    }