<!-- Source: https://docs.squirro.com/en/latest/api/squirro.lib.nlp.steps.classifiers.SmartfilterClassifier.html -->
# SmartfilterClassifier

**`class SmartfilterClassifier(config)`**

Bases: [`Classifier`](squirro.lib.nlp.steps.classifiers.Classifier.md#squirro.lib.nlp.steps.classifiers.Classifier)

The smartfilter [`Classifier`](squirro.lib.nlp.steps.classifiers.Classifier.md#squirro.lib.nlp.steps.classifiers.Classifier) uses the Elastic Search based highlight tags <squirro:highlight> and </squirro:highlight> to classify text fragments.

**Note** - The [`squirro.lib.nlp.steps.loaders.SquirroQueryLoader`](squirro.lib.nlp.steps.loaders.SquirroQueryLoader.md#squirro.lib.nlp.steps.loaders.SquirroQueryLoader) step needs to be run before this step, further make sure that search highlighting is switched on. It works with normal search queries and smartfilters.

**Input** - all input fields need to be of type [`str`](https://docs.python.org/3.11/library/stdtypes.html#str).

**Output** - the output field is filled with data of type [`str`](https://docs.python.org/3.11/library/stdtypes.html#str). It contains the extract which is encapsulated by the highlight tags. the lable_field is filled with the smartfilter_label.

Parameters

- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – smartfilter
- `words_threshold` ([`int`](https://docs.python.org/3.11/library/functions.html#int)`, ``1`) – Minimum number of highlighted words to be included as an extract.
- `smartfilter_label` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – Label added to document if it contains an extract.

**Example**

```json
{
  "step": "classifier",
  "type": "smartfilter",
  "input_field": "body",
  "output_field": "extract",
  "smartfilter_label": "classA",
  "label_field": "label"
}
```

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)
