shaheerawan3's picture
Rename config.py to utils/config.py
277674a verified
import yaml
from pathlib import Path
import os
def load_config():
"""Load configuration from YAML file"""
# Get the directory containing this script
current_dir = Path(__file__).parent.parent
config_path = current_dir / "config.yaml"
if not config_path.exists():
# Default configuration
config = {
'models': {
'spacy': 'en_core_web_sm',
'sentiment': 'nlptown/bert-base-multilingual-uncased-sentiment'
},
'analysis': {
'batch_size': 1000,
'min_entity_confidence': 0.8,
'num_topics': 3,
'max_text_length': 50000
},
'security': {
'max_file_size': 5242880, # 5MB
'allowed_extensions': ['txt']
},
'logging': {
'level': 'INFO',
'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
}
}
# Save default config
with open(config_path, 'w') as f:
yaml.dump(config, f, default_flow_style=False)
# Load config
with open(config_path) as f:
return yaml.safe_load(f)