Filter Tolokers with confirmed language knowledge

Use pool filters to filter the Tolokers with various languages for which they passed the language test.

Warning

Please note that this recipe will only currently work for the Toloka production environment, not for sandbox.

Steps to follow

1. Import Toloka-Kit

Connect the Toloka-Kit library to your script.

import toloka.client as toloka

2. Instantiate TolokaClient

Replace the sample API key with your own one.

toloka_client = toloka.
TolokaClient
('PlaceYourRealApiKey_Here', 'PRODUCTION');

3. Specify pool filter

Find out the ID of the pool where you want to add the language filter.

from toloka.client.primitives.operators import InclusionOperator

updated_pool = toloka_client.
get_pool
('38955320')

updated_pool.filter=(

(toloka.filter.
Languages
(operator=
InclusionOperator
.IN, value=['EN', 'DE'], verified=True)) &

(toloka.filter.
Languages
(operator=
InclusionOperator
.IN, value=['FR'], verified=True))

)

toloka_client.
update_pool
(pool_id=updated_pool.id, pool=updated_pool)
Tip

See the Filter Tolokers Toloka-Kit recipe for examples of other filters you can use for pools.

Languages filter in the Toloka interface

4. Print created pool filter

The update_pool() request will return the Pool class object. You can use its attributes to print the information you need.

print(updated_pool.filter)

You should get an output with the created pool filter which looks like this.

FilterAnd(_unexpected={}, and_=[FilterOr(_unexpected={}, or_=[FilterAnd(_unexpected={}, and_=[Languages(_unexpected={}, operator=<InclusionOperator.IN: 'IN'>, value='EN'), Skill(_unexpected={}, key='26366', operator=<CompareOperator.EQ: 'EQ'>, value=100)]), FilterAnd(_unexpected={}, and_=[Languages(_unexpected={}, operator=<InclusionOperator.IN: 'IN'>, value='DE'), Skill(_unexpected={}, key='26377', operator=<CompareOperator.EQ: 'EQ'>, value=100)])]), FilterOr(_unexpected={}, or_=[FilterAnd(_unexpected={}, and_=[Languages(_unexpected={}, operator=<InclusionOperator.IN: 'IN'>, value='FR'), Skill(_unexpected={}, key='26711', operator=<CompareOperator.EQ: 'EQ'>, value=100)])])])
Response description

Complete code: Filter Tolokers with confirmed language knowledge

import toloka.client as toloka
from toloka.client.primitives.operators import InclusionOperator
toloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', 'PRODUCTION')
updated_pool = toloka_client.get_pool('38955320')
updated_pool.filter=(
(toloka.filter.Languages(operator=InclusionOperator.IN, value=['EN', 'DE'], verified=True)) &
(toloka.filter.Languages(operator=InclusionOperator.IN, value=['FR'], verified=True))
)
toloka_client.update_pool(pool_id=updated_pool.id, pool=updated_pool)
print(updated_pool.filter)
List of classes and methods used in this recipe

See also

Last updated: July 20, 2023

Toloka-Kit
OverviewGetting API keyQuick start
Recipes
Reference
toloka.client
toloka.async_client
toloka.autoquality [autoquality]
toloka.metrics
toloka.streaming