alessandro trinca tornidor
		
	commited on
		
		
					Commit 
							
							·
						
						c2c8fde
	
1
								Parent(s):
							
							7f70db3
								
feat: spacy language model now is configurable
Browse files
    	
        my_ghost_writer/constants.py
    CHANGED
    
    | @@ -21,6 +21,7 @@ LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO") | |
| 21 | 
             
            API_MODE = bool(os.getenv("API_MODE", ""))
         | 
| 22 | 
             
            N_WORDS_GRAM = int(os.getenv("N_WORDS_GRAM", 2))
         | 
| 23 | 
             
            WORDNET_LANGUAGES=(os.getenv("WORDNET_LANGUAGES", "eng,"))
         | 
|  | |
| 24 | 
             
            WORDSAPI_KEY = os.getenv("WORDSAPI_KEY")
         | 
| 25 | 
             
            WORDSAPI_URL = os.getenv("WORDSAPI_URL", "https://wordsapiv1.p.rapidapi.com/words")
         | 
| 26 | 
             
            RAPIDAPI_HOST = os.getenv("RAPIDAPI_HOST", "wordsapiv1.p.rapidapi.com")
         | 
|  | |
| 21 | 
             
            API_MODE = bool(os.getenv("API_MODE", ""))
         | 
| 22 | 
             
            N_WORDS_GRAM = int(os.getenv("N_WORDS_GRAM", 2))
         | 
| 23 | 
             
            WORDNET_LANGUAGES=(os.getenv("WORDNET_LANGUAGES", "eng,"))
         | 
| 24 | 
            +
            SPACY_MODEL_NAME=os.getenv("SPACY_MODEL_NAME", "en_core_web_sm")
         | 
| 25 | 
             
            WORDSAPI_KEY = os.getenv("WORDSAPI_KEY")
         | 
| 26 | 
             
            WORDSAPI_URL = os.getenv("WORDSAPI_URL", "https://wordsapiv1.p.rapidapi.com/words")
         | 
| 27 | 
             
            RAPIDAPI_HOST = os.getenv("RAPIDAPI_HOST", "wordsapiv1.p.rapidapi.com")
         | 
    	
        my_ghost_writer/text_parsers2.py
    CHANGED
    
    | @@ -6,15 +6,16 @@ import pyinflect | |
| 6 | 
             
            from typing import List, Dict, Any, Optional
         | 
| 7 | 
             
            from fastapi import HTTPException
         | 
| 8 |  | 
| 9 | 
            -
            from my_ghost_writer.constants import app_logger
         | 
| 10 |  | 
| 11 |  | 
| 12 | 
             
            # Load spaCy model
         | 
| 13 | 
             
            try:
         | 
| 14 | 
            -
                nlp = spacy.load( | 
|  | |
| 15 | 
             
            except OSError:
         | 
| 16 | 
             
                app_logger.error(
         | 
| 17 | 
            -
                    "spaCy model ' | 
| 18 | 
             
                )
         | 
| 19 | 
             
                nlp = None
         | 
| 20 |  | 
|  | |
| 6 | 
             
            from typing import List, Dict, Any, Optional
         | 
| 7 | 
             
            from fastapi import HTTPException
         | 
| 8 |  | 
| 9 | 
            +
            from my_ghost_writer.constants import SPACY_MODEL_NAME, app_logger
         | 
| 10 |  | 
| 11 |  | 
| 12 | 
             
            # Load spaCy model
         | 
| 13 | 
             
            try:
         | 
| 14 | 
            +
                nlp = spacy.load(SPACY_MODEL_NAME)
         | 
| 15 | 
            +
                app_logger.info(f"spacy model {SPACY_MODEL_NAME} has type:'{type(nlp)}'")
         | 
| 16 | 
             
            except OSError:
         | 
| 17 | 
             
                app_logger.error(
         | 
| 18 | 
            +
                    f"spaCy model '{SPACY_MODEL_NAME}' not found. Please install it with: -python -m spacy download {SPACY_MODEL_NAME}'"
         | 
| 19 | 
             
                )
         | 
| 20 | 
             
                nlp = None
         | 
| 21 |  |