fix neutralization names
This commit is contained in:
parent
24b09ea7ce
commit
61734bc22d
1 changed files with 26 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue