fix neutralization names

This commit is contained in:
ValueOn AG 2025-11-02 00:54:56 +01:00
parent 24b09ea7ce
commit 61734bc22d

View file

@ -142,12 +142,38 @@ class NeutralizationService:
return False
return self.interfaceDbApp.deleteNeutralizationAttributes(fileId)
def _reloadNamesFromConfig(self) -> None:
"""Reload names from config and update processors"""
try:
config = self.getConfig()
if not config:
return
# Parse namesToParse string into list
names_list = []
if config.namesToParse:
names_list = [name.strip() for name in config.namesToParse.split('\n') if name.strip()]
# Update internal list
self.NamesToParse = names_list
# Recreate processors with updated names
self.textProcessor = TextProcessor(names_list)
self.listProcessor = ListProcessor(names_list)
logger.debug(f"Reloaded {len(names_list)} names from config")
except Exception as e:
logger.error(f"Error reloading names from config: {str(e)}")
# Continue with existing names if reload fails
# Helper functions
def _neutralizeText(self, text: str, textType: str = None) -> Dict[str, Any]:
"""Process text and return unified dict for API consumption."""
try:
# Reload names from config before processing to ensure we have the latest names
self._reloadNamesFromConfig()
# Auto-detect content type if not provided
if textType is None:
textType = self.commonUtils.detectContentType(text)