<!-- Source: https://docs.squirro.com/en/latest/api/squirro.lib.nlp.apps.query_processing.LemmaExpander.html -->
# LemmaExpander

**`class LemmaExpander(config)`**

Bases: [`BatchedStep`](../technical/libnlp/steps/standard.md#squirro.lib.nlp.steps.batched_step.BatchedStep)

Keep track of lemmatised version of relevant terms.

**Note**

- Can leverage pos_mutations from POSBooster to tag lemmas only for important terms.
- This metadata is then used to generate exact vs lemmatised ES query clauses (by ES query generator)

**Input**

- Uses field `nlp` (spacy.tokens.doc.Doc) that contains the analysed SpaCy Doc (from SpacyNormalizer).

**Output**

- Writes field `lemma_map` (dict) that contains the mapping of original term and its root form like `{'original': 'lemmatized'}`

Parameters

- `step` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``"app"`) – app
- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``"query_processing"`) – query_processing
- `name` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``"lemma_tagger"`) – lemma_tagger
- `analyzed_input_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`,``"nlp"`) – query
- `output_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`,``"lemma_map"`) – Tagged lemma terms
- `path` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`,``"."`) – .

Methods SummaryMethods Documentation

**`process_doc(doc)`**

Process a document

Parameters

`doc` ([`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)) – Document

Returns

Processed document

Return type

[Document](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)
