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

**`class SquirroEntityFilter(config)`**

Bases: [`Filter`](squirro.lib.nlp.steps.filters.Filter.md#squirro.lib.nlp.steps.filters.Filter)

The Squirro entitiy [`Filter`](squirro.lib.nlp.steps.filters.Filter.md#squirro.lib.nlp.steps.filters.Filter) takes a set of fields and creates the Squirro entities structure

**Note** - The [`squirro.lib.nlp.steps.tokenizers.PdfSentencesTokenizer`](squirro.lib.nlp.steps.tokenizers.PdfSentencesTokenizer.md#squirro.lib.nlp.steps.tokenizers.PdfSentencesTokenizer) need to be run before this step for PDF support

**Input** - There is no specific input field for this step.

**Output** - The output field is formatted as follows (page to rects is only produced for pdf files):

```json
[
  {
    "type": "ENTITY_TYPE",
    "name": "ENTITY_NAME",
    "extracts":[
       {
          "text":"TEXT_FRAGMENT",
          "offset":"OFFSET",
          "length":"LENGTH"
          "page_to_rects":{
             "PAGE_NUM":[{"x":"X", "y":"Y", "height":"H", "width":"W"}]
          },
       }
    ],
    "properties":{ "PROPERTY_KEY":["PROPERTY_VALUE"]}
  }
]
```

Parameters

- `entity_name` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``None`) – Name of entity (defaults to entity_type)
- `entity_name_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``None`) – Field with entity name (defaults to entity_name if None)
- `entity_type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – Type of the squirro entity, value of the type field in the entity data structure
- `excluded_values` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`, ``[``]`) – Values that will not be added as entity properties
- `extract_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – Field with list of text extracts
- `format_values` ([`bool`](https://docs.python.org/3.11/library/functions.html#bool)`, ``False`) – Whether or not to format string values as titles
- `global_property_field_map` ([`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)`, ``{}`) – Map for fields with properties that are copied in from the item
- `output_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``'entities'`) – Field to write resulting entities
- `property_field_map` ([`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)`, ``{}`) – Map for fields with properties that match the number of extracts
- `property_value_map` ([`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)`, ``{}`) – Map for renaming values of fields with properties that match the number of extracts
- `static_properties` ([`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)`, ``{}`) – Map of static property values to attach to entities
- `required_properties` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`, ``[``]`) – Properties that must exist (after exclusion) for the entity to be added
- `source_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``''`) – Field where extracted text originated
- `source_fields` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`, ``[``]`) – List of fields where extracted text originated

**Example**

```json
{
    "step": "filter",
    "type": "squirro_entity",
    "entity_name_field": "prediction",
    "entity_type": "ENTITY_TYPE",
    "excluded_values": [],
    "extract_field": "sentences",
    "format_values": false,
    "global_property_field_map": {},
    "modes": ["process"],
    "property_field_map": {
        "PROPERTY_KEY": ["prediction"]
    },
    "required_properties": ["PROPERTY_KEY"],
    "source_field": "body"
}
```

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)
