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

**`class BowEmbedder(config)`**

Bases: [`Embedder`](squirro.lib.nlp.steps.embedders.Embedder.md#squirro.lib.nlp.steps.embedders.Embedder)

The bag of words [`Embedder`](squirro.lib.nlp.steps.embedders.Embedder.md#squirro.lib.nlp.steps.embedders.Embedder) encodes provided text based on gensim [doc2bow](https://radimrehurek.com/gensim/corpora/dictionary.html#gensim.corpora.dictionary.Dictionary.doc2bow).

**Intput** - the input field needs to be of type [`list`](https://docs.python.org/3.11/library/stdtypes.html#list) [ [`str`](https://docs.python.org/3.11/library/stdtypes.html#str) ]

**Output**  - the output field is filled with data of type `numpy.ndarray`

Parameters

- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – bow
- `min_doc_frequency` ([`int`](https://docs.python.org/3.11/library/functions.html#int)`, ``2`) – Minimum number of documents a term must appear in
- `max_doc_fraction` ([`float`](https://docs.python.org/3.11/library/functions.html#float)`, ``0.75`) – Maximum fraction of documents a term can appear in
- `max_n_words` ([`int`](https://docs.python.org/3.11/library/functions.html#int)`, ``None`) – Maximum dictionary size

**Example**

```json
{
    "step": "embedder",
    "type": "bow",
    "input_field": "text",
    "output_field": "embedded_text"
}
```

Methods SummaryMethods Documentation

**`load()`**

Load a step

**`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`](https://docs.python.org/3.11/library/stdtypes.html#list)`(`[`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)`)`) – List of documents

Returns

List of processed documents

Return type

[list](https://docs.python.org/3.11/library/stdtypes.html#list)([Document](../technical/libnlp/base.md#squirro.lib.nlp.document.Document))

**`save()`**

Save a step

**`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))
