add punkt installer

This commit is contained in:
Cyberes 2024-04-27 22:43:24 -06:00
parent 2e80ccceab
commit 15557188d8
2 changed files with 9 additions and 2 deletions

10
punkt-download.py Normal file → Executable file
View File

@ -1,9 +1,17 @@
#!/usr/bin/env python3
import os
import shutil
from pathlib import Path
import nltk
script_dir = Path(os.path.dirname(os.path.realpath(__file__)))
target = script_dir / 'punkt'
print('Downloading punkt to:', target)
print('Target directory:', target)
print('Erasing old install...')
shutil.rmtree(target, ignore_errors=True)
print('Downloading punkt...')
nltk.download('punkt', download_dir=target)

View File

@ -68,7 +68,6 @@ async def startup_event():
if not (script_dir / 'punkt' / 'tokenizers' / 'punkt').is_dir():
logger.critical(f'Punkt not found at "{script_dir}/punkt". Please run "./punkt-download.py" first.')
sys.exit(1)
nltk.download('punkt', download_dir=script_dir / 'punkt')
q = asyncio.Queue()
app.model_queue = q
await asyncio.create_task(server_loop(q))