Spaces:
Sleeping
Sleeping
File size: 1,226 Bytes
8adead2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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) |