aus10powell commited on
Commit
840c525
1 Parent(s): 9f54156

Update app.py

Browse files

load spacy on app start

Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -59,6 +59,10 @@ username_list = [
59
  start_date = dt.date(year=2023, month=2, day=1)
60
  end_date = dt.date(year=2023, month=3, day=22)
61
 
 
 
 
 
62
 
63
  @app.get("/", response_class=HTMLResponse)
64
  async def webpage(request: Request):
@@ -281,9 +285,6 @@ async def generate_summary(request: Request):
281
  # Concatenate tweets into a single string
282
  text = " .".join(tweets)
283
 
284
- nlp = spacy.load("en_core_web_sm")
285
- nlp.add_pipe("sentencizer")
286
-
287
  sentences = nlp(text).sents
288
 
289
  sentences = list(sentences)
 
59
  start_date = dt.date(year=2023, month=2, day=1)
60
  end_date = dt.date(year=2023, month=3, day=22)
61
 
62
+ # Load spacy module on app start
63
+ nlp = spacy.load("en_core_web_sm")
64
+ nlp.add_pipe("sentencizer")
65
+
66
 
67
  @app.get("/", response_class=HTMLResponse)
68
  async def webpage(request: Request):
 
285
  # Concatenate tweets into a single string
286
  text = " .".join(tweets)
287
 
 
 
 
288
  sentences = nlp(text).sents
289
 
290
  sentences = list(sentences)