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

**`class DocSplitFilter(config)`**

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

The doc_split [`Filter`](squirro.lib.nlp.steps.filters.Filter.md#squirro.lib.nlp.steps.filters.Filter) splits a single [`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document) into many via iterable fields of the same length.

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

**Output** - The output fields are going to be of type [`object`](https://docs.python.org/3.11/library/functions.html#object).

Parameters

- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – doc_split
- `fields` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)) – Fields to split on (must all be same length)
- `flatten` ([`bool`](https://docs.python.org/3.11/library/functions.html#bool)`, ``False`) – Whether or not to flatten the split fields
- `copy_fields` ([`bool`](https://docs.python.org/3.11/library/functions.html#bool)`, ``False`) – Whether to refer or copy the other fields of the document
  to the new generated documents. If you expect to mutate the other fields of the
  generated document in subsequent steps, then set this parameter to true. However,
  please note that this may come with a performance penalty when the document
  has many number of elements for the defined fields.

**Example**

```json
{
    "step": "filter",
    "type": "doc_split",
    "fields":["sentences"]
}
```

Methods SummaryMethods Documentation

**`process(docs)`**

Process a set of documents

Parameters

`docs` (`generator``(`[`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)`)`) – Generator of documents

Returns

Generator of processed documents

Return type

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

**`train(docs)`**

Train on a step of a set of documents

Parameters

`docs` (`generator``(`[`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)`)`) – Generator of documents

Returns

Generator of processed documents

Return type

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