diff --git a/punkt-download.py b/punkt-download.py old mode 100644 new mode 100755 index 0b00ca8..430bfc8 --- a/punkt-download.py +++ b/punkt-download.py @@ -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) diff --git a/server.py b/server.py index ef7ae44..a1a5b1d 100644 --- a/server.py +++ b/server.py @@ -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))