import json import re from typing import Dict, List, TypedDict from .config import Config class Intents(TypedDict): ask_name: List[str] class NaturalLanguageProcessor: def __init__(self, config: Config): with config.data_path.open('r', encoding='utf-8') as file: self.intents: Dict[str, List[str]] = json.load(file) def analyze(self, input_text: str) -> str: input_text = input_text.lower() for intent, patterns in self.intents.items(): for pattern in patterns: if re.search(pattern, input_text): return intent return "unknown"