"""Implementation of nlp_worker.""" import logging import nlp_ws from src.anonymizer import Anonymizer from src.ccl_handler import CCLHandler _log = logging.getLogger(__name__) class Worker(nlp_ws.NLPWorker): """Implements nlp_worker for anonymizer service.""" def process(self, input_file, task_options, output_file): """Anonymizes input text. It is assumed input_file is encoded in UTF-8. Options: method - 'delete'/'tag'/'pseudo' - 'delete' deletes selected tokens, 'tag' replaces selected tokens with arbitrary tags, 'pseudo' replaces selected tokens with a random token that """ anon = Anonymizer(task_options) ccl_handler = CCLHandler(input_file) ccl_handler.process(output_file, anon.unmarshallers)