ConditionStep#

class squirro.lib.nlp.steps.flow.ConditionStep(config)#

Bases: squirro.lib.nlp.steps.batched_step.BatchedStep

Step that executes other steps based on provided condition.

Parameters
  • step (str) – flow

  • type (str) – condition

  • condition (dict) – Condition based on which the step to be executed is selected. If declared condition passed, the step defined in the “true_step” key is executed, otherwise the step from the “false_step” key is chosen. Available conditions: healthy_service.

  • true_step (dict) – Step configuration that should be executed when condition is true.

  • false_step (dict) – Step configuration that should be executed when condition is false.

Example

{
    "step": "flow",
    "type": "condition",
    "condition": {
        "healthy_service": {
            "service_name": "nlp"
        }
    },
    "true_step": {
        "step": "external",
        "type": "nlp_service_spacy",
        "name": "nlp_service_spacy",
        "field_mapping": {
            "user_terms_str": "nlp"
        },
        "pipeline__default": "en:fast",
        "disable_pipes__default": ["merge_noun_chunks"],
        "language_processor_mapping": {
            "de": "de:fast",
            "en": "en:fast"
        }
    },
    "false_step": {
        "step": "app",
        "type": "query_processing",
        "name": "custom_spacy_normalizer",
        "model_cache_expiration": 345600,
        "infix_split_hyphen": false,
        "infix_split_chars": ":<>=",
        "merge_noun_chunks": false,
        "merge_phrases": true,
        "merge_entities": true,
        "fallback_language": "en",
        "exclude_spacy_pipes": [],
        "spacy_model_mapping": {
            "en": "en_core_web_sm",
            "de": "de_core_news_sm"
        }
    }
}

Methods Summary

choose_step_config()

rtype

dict

is_condition_true(**kwargs)

process_batch(batch)

Process a batch of documents.

Methods Documentation

choose_step_config()#
Return type

dict

is_condition_true(**kwargs)#
process_batch(batch)#

Process a batch of documents. If not defined will default to using self.process_doc for each document in the batch.

Parameters

batch (list(Document)) – List of documents

Returns

List of processed documents

Return type

list(Document)