# TokenSearcherNER

This task uses[ **TokenSearcherPredictor**](https://utca.knowledgator.com/predictors/tokensearcherpredictor)[ ](https://utca.knowledgator.com/predictors/comprehenditpredictor)by default. For more details, see:

{% content-ref url="../predictors/tokensearcherpredictor" %}
[tokensearcherpredictor](https://utca.knowledgator.com/predictors/tokensearcherpredictor)
{% endcontent-ref %}

Subclass of [**NERTask**](https://utca.knowledgator.com/task#nertask)**.**&#x20;

## Module: [implementation](https://utca.knowledgator.com/framework-structure#implementation).tasks

## Methods and properties

Main methods and properties

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**predictor**</mark>**&#x20;(**[**Predictor**](https://utca.knowledgator.com/predictors/predictor)**\[Any, Any], optional):** Predictor that will be used in task. If equals to None, default [**TokenSearcherPredictor**](https://utca.knowledgator.com/predictors/tokensearcherpredictor) will be used. Defaults to None.
* <mark style="color:orange;">**preprocess**</mark>**&#x20;(Optional\[**[**Component**](https://utca.knowledgator.com/core/component)**], optional):** Component executed before predictor. If equals to None, default component will be used. Defaults to None.\
  \
  Default component: \
  [**TokenSearcherNERPreprocessor**](#tokensearchernerpreprocessor)
* <mark style="color:orange;">**postprocess**</mark>**&#x20;(Optional\[**[**Component**](https://utca.knowledgator.com/core/component)**], optional):** Component executed after predictor. If equals to None, default component will be used. Defaults to None.\
  \
  Default component: \
  [**TokenSearcherNERPostprocessor**](#tokensearchernerpostprocessor)
* <mark style="color:orange;">**input\_class**</mark>**&#x20;(Type\[**[**Input**](https://utca.knowledgator.com/core/schemas#input)**], optional):** Class for input validation. Defaults to [**TokenSearcherNERInput**](#tokensearchernerinput)**.**
* <mark style="color:orange;">**output\_class**</mark>**&#x20;(Type\[**[**NEROutputType**](https://utca.knowledgator.com/task#neroutputtype)**], optional):** Class for output validation. Defaults to [**TokenSearcherNEROutput**](#tokensearcherneroutput)**.**
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.

***

***

***

## <mark style="color:green;">TokenSearcherNERInput</mark>

Subclass of [**IOModel**](https://utca.knowledgator.com/core/schemas#iomodel)**.**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**text**</mark>**&#x20;(str):** Text to clean.
* <mark style="color:orange;">**labels**</mark>**&#x20;(List\[str]):** Labels for classification.

***

***

***

## <mark style="color:green;">TokenSearcherNEROutput</mark>

Subclass of [**NEROutput**](https://utca.knowledgator.com/task#neroutput). Type of [**NEROutput**](https://utca.knowledgator.com/task#neroutput)**\[**[**ClassifiedEntity**](https://utca.knowledgator.com/objects#classifiedentity)**].**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**text**</mark>**&#x20;(str):** Input text.
* <mark style="color:orange;">**output**</mark>**&#x20;(List\[**[**ClassifiedEntity**](https://utca.knowledgator.com/objects#classifiedentity)**]):** Classified entities.

***

***

***

## <mark style="color:green;">TokenSearcherNERPreprocessor</mark>

Create prompts with providied text. Subclass of [**Action**](https://utca.knowledgator.com/core/action). Type of [**Action**](https://utca.knowledgator.com/core/action)**\[Dict\[str, Any], Dict\[str, Any]].**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**sents\_batch**</mark>**&#x20;(int):** Chunks size in sentences. Defaults to 10.
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):** \
  Expected keys:
  * <mark style="color:red;">**"text"**</mark>**&#x20;(str):** Text to process;
  * <mark style="color:red;">**"labels"**</mark> **(List\[str]):** Labels for classification;

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:
  * <mark style="color:red;">**"inputs"**</mark>**&#x20;(List\[str]):** Model inputs;
  * <mark style="color:red;">**"chunks\_starts"**</mark>**&#x20;(List\[int]):** Chunks start positions. Used by postprocessor;
  * <mark style="color:red;">**"prompt\_lengths"**</mark>**&#x20;(List\[int]):** Prompt lenghts. Used by postprocessor;

***

***

***

## <mark style="color:green;">TokenSearcherNERPostprocessor</mark>

Format output. Subclass of [**Action**](https://utca.knowledgator.com/core/action). Type of [**Action**](https://utca.knowledgator.com/core/action)**\[Dict\[str, Any], Dict\[str, Any]].**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**threshold**</mark>**&#x20;(float):** Entities threshold score. Defaults to 0.
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):** \
  Expected keys:
  * <mark style="color:red;">**"output"**</mark>**&#x20;(List\[List\[Dict\[str, Any]]]):** Model output;
  * <mark style="color:red;">**"labels"**</mark> **(List\[str]):** Labels for classification;
  * <mark style="color:red;">**"text"**</mark>**&#x20;(str):** Processed text;
  * <mark style="color:red;">**"chunks\_starts"**</mark>**&#x20;(List\[int]):** Chunks start positions;
  * <mark style="color:red;">**"prompt\_lengths"**</mark>**&#x20;(List\[int]):** Prompt lenghts;

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:
  * <mark style="color:red;">**"text"**</mark>**&#x20;(str):** Processed text;
  * <mark style="color:red;">**"output"**</mark>**&#x20;(List\[**[**ClassifiedEntity**](https://utca.knowledgator.com/objects#classifiedentity)**]):** Classified entities;

***

***
