rapidata 1.10.1__py3-none-any.whl → 2.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rapidata might be problematic. Click here for more details.
- rapidata/__init__.py +22 -17
- rapidata/api_client/__init__.py +16 -5
- rapidata/api_client/api/coco_api.py +14 -29
- rapidata/api_client/api/dataset_api.py +6 -6
- rapidata/api_client/api/identity_api.py +3 -3
- rapidata/api_client/api/pipeline_api.py +1008 -95
- rapidata/api_client/api/rapid_api.py +6 -6
- rapidata/api_client/api/validation_api.py +12 -42
- rapidata/api_client/models/__init__.py +16 -5
- rapidata/api_client/models/add_campaign_model.py +5 -5
- rapidata/api_client/models/add_validation_text_rapid_model.py +1 -1
- rapidata/api_client/models/age_group.py +5 -4
- rapidata/api_client/models/base_error.py +1 -4
- rapidata/api_client/models/compare_workflow_config.py +9 -24
- rapidata/api_client/models/compare_workflow_config_model.py +9 -29
- rapidata/api_client/models/compare_workflow_config_model_pair_maker_config.py +140 -0
- rapidata/api_client/models/compare_workflow_config_pair_maker_config.py +140 -0
- rapidata/api_client/models/compare_workflow_model.py +7 -3
- rapidata/api_client/models/compare_workflow_model1.py +7 -3
- rapidata/api_client/models/compare_workflow_model1_pair_maker_information.py +140 -0
- rapidata/api_client/models/compare_workflow_model_pair_maker_config.py +140 -0
- rapidata/api_client/models/create_order_model.py +4 -2
- rapidata/api_client/models/create_order_model_user_filters_inner.py +25 -11
- rapidata/api_client/models/custom_user_filter_model.py +98 -0
- rapidata/api_client/models/file_asset_model_metadata_inner.py +8 -22
- rapidata/api_client/models/get_classify_workflow_result_overview_result.py +144 -0
- rapidata/api_client/models/get_pipeline_by_id_result.py +13 -3
- rapidata/api_client/models/identity_read_bridge_token_get202_response.py +140 -0
- rapidata/api_client/models/not_available_yet_result.py +96 -0
- rapidata/api_client/models/online_pair_maker_config.py +98 -0
- rapidata/api_client/models/online_pair_maker_config_model.py +98 -0
- rapidata/api_client/models/online_pair_maker_information.py +100 -0
- rapidata/api_client/models/pipeline_id_workflow_put_request.py +140 -0
- rapidata/api_client/models/pre_arranged_pair_maker_config.py +100 -0
- rapidata/api_client/models/pre_arranged_pair_maker_config_model.py +96 -0
- rapidata/api_client/models/pre_arranged_pair_maker_information.py +102 -0
- rapidata/api_client/models/read_bridge_token_keys_result.py +11 -2
- rapidata/api_client/models/simple_workflow_config.py +7 -26
- rapidata/api_client/models/simple_workflow_config_model.py +4 -28
- rapidata/api_client/models/simple_workflow_get_result_overview_get200_response.py +16 -16
- rapidata/api_client/models/simple_workflow_model1.py +3 -3
- rapidata/api_client/models/update_campaign_model.py +99 -0
- rapidata/api_client/models/validation_import_post_request_blueprint.py +1 -1
- rapidata/api_client_README.md +21 -7
- rapidata/rapidata_client/__init__.py +20 -10
- rapidata/rapidata_client/assets/__init__.py +5 -4
- rapidata/rapidata_client/assets/{media_asset.py → _media_asset.py} +32 -11
- rapidata/rapidata_client/assets/{multi_asset.py → _multi_asset.py} +1 -1
- rapidata/rapidata_client/assets/{text_asset.py → _text_asset.py} +1 -1
- rapidata/rapidata_client/assets/data_type_enum.py +7 -0
- rapidata/rapidata_client/filter/__init__.py +2 -1
- rapidata/rapidata_client/filter/_base_filter.py +10 -0
- rapidata/rapidata_client/filter/age_filter.py +12 -5
- rapidata/rapidata_client/filter/campaign_filter.py +12 -3
- rapidata/rapidata_client/filter/country_filter.py +10 -3
- rapidata/rapidata_client/filter/custom_filter.py +29 -0
- rapidata/rapidata_client/filter/gender_filter.py +12 -5
- rapidata/rapidata_client/filter/language_filter.py +14 -3
- rapidata/rapidata_client/filter/models/age_group.py +26 -0
- rapidata/rapidata_client/filter/models/gender.py +19 -0
- rapidata/rapidata_client/filter/rapidata_filters.py +35 -0
- rapidata/rapidata_client/filter/user_score_filter.py +20 -4
- rapidata/rapidata_client/metadata/__init__.py +5 -5
- rapidata/rapidata_client/metadata/{base_metadata.py → _base_metadata.py} +2 -1
- rapidata/rapidata_client/metadata/{private_text_metadata.py → _private_text_metadata.py} +2 -2
- rapidata/rapidata_client/metadata/{prompt_metadata.py → _prompt_metadata.py} +3 -2
- rapidata/rapidata_client/metadata/{public_text_metadata.py → _public_text_metadata.py} +2 -2
- rapidata/rapidata_client/metadata/{select_words_metadata.py → _select_words_metadata.py} +3 -2
- rapidata/rapidata_client/{dataset/rapidata_dataset.py → order/_rapidata_dataset.py} +7 -8
- rapidata/rapidata_client/order/_rapidata_order_builder.py +365 -0
- rapidata/rapidata_client/order/rapidata_order.py +50 -32
- rapidata/rapidata_client/order/rapidata_order_manager.py +461 -0
- rapidata/rapidata_client/rapidata_client.py +12 -201
- rapidata/rapidata_client/referee/__init__.py +3 -3
- rapidata/rapidata_client/referee/{base_referee.py → _base_referee.py} +3 -3
- rapidata/rapidata_client/referee/{early_stopping_referee.py → _early_stopping_referee.py} +14 -11
- rapidata/rapidata_client/referee/{naive_referee.py → _naive_referee.py} +9 -9
- rapidata/rapidata_client/selection/__init__.py +1 -1
- rapidata/rapidata_client/{filter/base_filter.py → selection/_base_selection.py} +2 -2
- rapidata/rapidata_client/selection/capped_selection.py +15 -5
- rapidata/rapidata_client/selection/conditional_validation_selection.py +17 -4
- rapidata/rapidata_client/selection/demographic_selection.py +18 -7
- rapidata/rapidata_client/selection/labeling_selection.py +10 -3
- rapidata/rapidata_client/selection/rapidata_selections.py +21 -0
- rapidata/rapidata_client/selection/validation_selection.py +11 -4
- rapidata/rapidata_client/settings/__init__.py +9 -2
- rapidata/rapidata_client/settings/_rapidata_setting.py +11 -0
- rapidata/rapidata_client/settings/alert_on_fast_response.py +21 -0
- rapidata/rapidata_client/settings/custom_setting.py +16 -0
- rapidata/rapidata_client/settings/free_text_minimum_characters.py +16 -0
- rapidata/rapidata_client/settings/models/__init__.py +1 -0
- rapidata/rapidata_client/settings/models/translation_behaviour_options.py +14 -0
- rapidata/rapidata_client/settings/no_shuffle.py +16 -0
- rapidata/rapidata_client/settings/play_video_until_the_end.py +16 -0
- rapidata/rapidata_client/settings/rapidata_settings.py +31 -0
- rapidata/rapidata_client/settings/translation_behaviour.py +18 -0
- rapidata/rapidata_client/validation/__init__.py +1 -0
- rapidata/rapidata_client/{dataset/validation_rapid_parts.py → validation/_validation_rapid_parts.py} +7 -6
- rapidata/rapidata_client/validation/_validation_set_builder.py +371 -0
- rapidata/rapidata_client/{dataset → validation}/rapidata_validation_set.py +54 -50
- rapidata/rapidata_client/validation/rapids/__init__.py +1 -0
- rapidata/rapidata_client/validation/rapids/box.py +17 -0
- rapidata/rapidata_client/validation/rapids/rapids.py +94 -0
- rapidata/rapidata_client/validation/rapids/rapids_manager.py +163 -0
- rapidata/rapidata_client/validation/validation_set_manager.py +338 -0
- rapidata/rapidata_client/workflow/__init__.py +8 -6
- rapidata/rapidata_client/workflow/_base_workflow.py +25 -0
- rapidata/rapidata_client/workflow/{classify_workflow.py → _classify_workflow.py} +6 -6
- rapidata/rapidata_client/workflow/{compare_workflow.py → _compare_workflow.py} +10 -16
- rapidata/rapidata_client/workflow/_draw_workflow.py +22 -0
- rapidata/rapidata_client/workflow/_evaluation_workflow.py +26 -0
- rapidata/rapidata_client/workflow/{free_text_workflow.py → _free_text_workflow.py} +10 -16
- rapidata/rapidata_client/workflow/_locate_workflow.py +22 -0
- rapidata/rapidata_client/workflow/{select_words_workflow.py → _select_words_workflow.py} +2 -8
- rapidata/service/credential_manager.py +11 -1
- rapidata/service/openapi_service.py +23 -4
- {rapidata-1.10.1.dist-info → rapidata-2.1.0.dist-info}/METADATA +2 -1
- {rapidata-1.10.1.dist-info → rapidata-2.1.0.dist-info}/RECORD +122 -96
- rapidata/constants.py +0 -1
- rapidata/rapidata_client/dataset/rapid_builders/__init__.py +0 -4
- rapidata/rapidata_client/dataset/rapid_builders/base_rapid_builder.py +0 -33
- rapidata/rapidata_client/dataset/rapid_builders/classify_rapid_builders.py +0 -166
- rapidata/rapidata_client/dataset/rapid_builders/compare_rapid_builders.py +0 -145
- rapidata/rapidata_client/dataset/rapid_builders/rapids.py +0 -33
- rapidata/rapidata_client/dataset/rapid_builders/select_words_rapid_builders.py +0 -124
- rapidata/rapidata_client/dataset/validation_set_builder.py +0 -336
- rapidata/rapidata_client/order/order_builder.py +0 -25
- rapidata/rapidata_client/order/rapidata_order_builder.py +0 -463
- rapidata/rapidata_client/selection/base_selection.py +0 -9
- rapidata/rapidata_client/settings/feature_flags.py +0 -125
- rapidata/rapidata_client/settings/settings.py +0 -124
- rapidata/rapidata_client/simple_builders/__init__.py +0 -0
- rapidata/rapidata_client/simple_builders/simple_classification_builders.py +0 -271
- rapidata/rapidata_client/simple_builders/simple_compare_builders.py +0 -267
- rapidata/rapidata_client/simple_builders/simple_free_text_builders.py +0 -192
- rapidata/rapidata_client/simple_builders/simple_select_words_builders.py +0 -196
- rapidata/rapidata_client/workflow/base_workflow.py +0 -42
- rapidata/rapidata_client/workflow/evaluation_workflow.py +0 -15
- /rapidata/rapidata_client/assets/{base_asset.py → _base_asset.py} +0 -0
- /rapidata/rapidata_client/{dataset → filter/models}/__init__.py +0 -0
- {rapidata-1.10.1.dist-info → rapidata-2.1.0.dist-info}/LICENSE +0 -0
- {rapidata-1.10.1.dist-info → rapidata-2.1.0.dist-info}/WHEEL +0 -0
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from rapidata.api_client.models.attach_category_truth import AttachCategoryTruth
|
|
3
|
-
from rapidata.api_client.models.classify_payload import ClassifyPayload
|
|
4
|
-
from rapidata.api_client.models.compare_payload import ComparePayload
|
|
5
|
-
from rapidata.api_client.models.compare_truth import CompareTruth
|
|
6
|
-
from rapidata.api_client.models.transcription_payload import TranscriptionPayload
|
|
7
|
-
from rapidata.api_client.models.transcription_truth import TranscriptionTruth
|
|
8
|
-
from rapidata.api_client.models.transcription_word import TranscriptionWord
|
|
9
|
-
from rapidata.rapidata_client.assets.media_asset import MediaAsset
|
|
10
|
-
from rapidata.rapidata_client.assets.multi_asset import MultiAsset
|
|
11
|
-
from rapidata.rapidata_client.assets.text_asset import TextAsset
|
|
12
|
-
from rapidata.rapidata_client.dataset.rapidata_validation_set import (
|
|
13
|
-
RapidataValidationSet,
|
|
14
|
-
)
|
|
15
|
-
from rapidata.rapidata_client.dataset.validation_rapid_parts import ValidatioRapidParts
|
|
16
|
-
from rapidata.rapidata_client.metadata.base_metadata import Metadata
|
|
17
|
-
from rapidata.service.openapi_service import OpenAPIService
|
|
18
|
-
|
|
19
|
-
from rapidata.rapidata_client.dataset.rapid_builders.rapids import (
|
|
20
|
-
Rapid,
|
|
21
|
-
ClassificationRapid,
|
|
22
|
-
CompareRapid,
|
|
23
|
-
SelectWordsRapid
|
|
24
|
-
)
|
|
25
|
-
from deprecated import deprecated
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class ValidationSetBuilder:
|
|
29
|
-
"""The ValidationSetBuilder is used to build a validation set.
|
|
30
|
-
Give the validation set a name and then add classify, compare, or transcription rapid parts to it.
|
|
31
|
-
Get a `ValidationSetBuilder` by calling [`rapi.new_validation_set()`](../rapidata_client.md/#rapidata.rapidata_client.rapidata_client.RapidataClient.new_validation_set).
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
def __init__(self, name: str, openapi_service: OpenAPIService):
|
|
35
|
-
"""
|
|
36
|
-
Initialize the ValidationSetBuilder.
|
|
37
|
-
|
|
38
|
-
Args:
|
|
39
|
-
name (str): The name of the validation set.
|
|
40
|
-
openapi_service (OpenAPIService): An instance of OpenAPIService to interact with the API.
|
|
41
|
-
"""
|
|
42
|
-
self.name = name
|
|
43
|
-
self.openapi_service = openapi_service
|
|
44
|
-
self.validation_set_id: str | None = None
|
|
45
|
-
self._rapid_parts: list[ValidatioRapidParts] = []
|
|
46
|
-
|
|
47
|
-
def submit(self) -> RapidataValidationSet:
|
|
48
|
-
"""Create the validation set by executing all HTTP requests. This should be the last method called on the builder.
|
|
49
|
-
|
|
50
|
-
Returns:
|
|
51
|
-
RapidataValidationSet: A RapidataValidationSet instance.
|
|
52
|
-
|
|
53
|
-
Raises:
|
|
54
|
-
ValueError: If the validation set creation fails.
|
|
55
|
-
"""
|
|
56
|
-
result = (
|
|
57
|
-
self.openapi_service.validation_api.validation_create_validation_set_post(
|
|
58
|
-
name=self.name
|
|
59
|
-
)
|
|
60
|
-
)
|
|
61
|
-
self.validation_set_id = result.validation_set_id
|
|
62
|
-
|
|
63
|
-
if self.validation_set_id is None:
|
|
64
|
-
raise ValueError("Failed to create validation set")
|
|
65
|
-
|
|
66
|
-
validation_set = RapidataValidationSet(
|
|
67
|
-
validation_set_id=self.validation_set_id,
|
|
68
|
-
openapi_service=self.openapi_service,
|
|
69
|
-
name=self.name,
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
for rapid_part in self._rapid_parts:
|
|
73
|
-
validation_set.add_general_validation_rapid(
|
|
74
|
-
payload=rapid_part.payload,
|
|
75
|
-
truths=rapid_part.truths,
|
|
76
|
-
metadata=rapid_part.metadata,
|
|
77
|
-
asset=rapid_part.asset,
|
|
78
|
-
randomCorrectProbability=rapid_part.randomCorrectProbability,
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
return validation_set
|
|
82
|
-
|
|
83
|
-
@deprecated("Use submit instead")
|
|
84
|
-
def create(self) -> RapidataValidationSet:
|
|
85
|
-
"""Create the validation set by executing all HTTP requests. This should be the last method called on the builder.
|
|
86
|
-
|
|
87
|
-
Returns:
|
|
88
|
-
RapidataValidationSet: A RapidataValidationSet instance.
|
|
89
|
-
|
|
90
|
-
Raises:
|
|
91
|
-
ValueError: If the validation set creation fails.
|
|
92
|
-
"""
|
|
93
|
-
return self.submit()
|
|
94
|
-
|
|
95
|
-
def add_rapid(self, rapid: Rapid):
|
|
96
|
-
"""Add a rapid to the validation set.
|
|
97
|
-
To create the Rapid, use the RapidataClient.rapid_builder instance.
|
|
98
|
-
|
|
99
|
-
Args:
|
|
100
|
-
rapid (Rapid): The rapid to add to the validation set.
|
|
101
|
-
"""
|
|
102
|
-
if not isinstance(rapid, Rapid):
|
|
103
|
-
raise ValueError("This method only accepts Rapid instances")
|
|
104
|
-
|
|
105
|
-
if isinstance(rapid, ClassificationRapid):
|
|
106
|
-
self._add_classify_rapid(rapid.asset, rapid.question, rapid.options, rapid.truths, rapid.metadata)
|
|
107
|
-
|
|
108
|
-
if isinstance(rapid, CompareRapid):
|
|
109
|
-
self._add_compare_rapid(rapid.asset, rapid.criteria, rapid.truth, rapid.metadata)
|
|
110
|
-
|
|
111
|
-
if isinstance(rapid, SelectWordsRapid):
|
|
112
|
-
self._add_select_words_rapid(rapid.asset, rapid.instruction, rapid.text, rapid.truths, rapid.strict_grading)
|
|
113
|
-
|
|
114
|
-
return self
|
|
115
|
-
|
|
116
|
-
@deprecated("Use add_rapid instead")
|
|
117
|
-
def add_classify_rapid(
|
|
118
|
-
self,
|
|
119
|
-
asset: MediaAsset | TextAsset,
|
|
120
|
-
question: str,
|
|
121
|
-
categories: list[str],
|
|
122
|
-
truths: list[str],
|
|
123
|
-
metadata: list[Metadata] = [],
|
|
124
|
-
):
|
|
125
|
-
"""Add a classify rapid to the validation set.
|
|
126
|
-
|
|
127
|
-
Args:
|
|
128
|
-
asset (MediaAsset | TextAsset): The asset for the rapid.
|
|
129
|
-
question (str): The question for the rapid.
|
|
130
|
-
categories (list[str]): The list of categories for the rapid.
|
|
131
|
-
truths (list[str]): The list of truths for the rapid.
|
|
132
|
-
metadata (list[Metadata], optional): The metadata for the rapid. Defaults to an empty list.
|
|
133
|
-
|
|
134
|
-
Returns:
|
|
135
|
-
ValidationSetBuilder: The ValidationSetBuilder instance.
|
|
136
|
-
|
|
137
|
-
Raises:
|
|
138
|
-
ValueError: If the lengths of categories and truths are inconsistent.
|
|
139
|
-
"""
|
|
140
|
-
self._add_classify_rapid(asset, question, categories, truths, metadata)
|
|
141
|
-
|
|
142
|
-
return self
|
|
143
|
-
|
|
144
|
-
def _add_classify_rapid(
|
|
145
|
-
self,
|
|
146
|
-
asset: MediaAsset | TextAsset,
|
|
147
|
-
question: str,
|
|
148
|
-
categories: list[str],
|
|
149
|
-
truths: list[str],
|
|
150
|
-
metadata: list[Metadata] = [],
|
|
151
|
-
):
|
|
152
|
-
"""Add a classify rapid to the validation set.
|
|
153
|
-
|
|
154
|
-
Args:
|
|
155
|
-
asset (MediaAsset | TextAsset): The asset for the rapid.
|
|
156
|
-
question (str): The question for the rapid.
|
|
157
|
-
categories (list[str]): The list of categories for the rapid.
|
|
158
|
-
truths (list[str]): The list of truths for the rapid.
|
|
159
|
-
metadata (list[Metadata], optional): The metadata for the rapid. Defaults to an empty list.
|
|
160
|
-
|
|
161
|
-
Returns:
|
|
162
|
-
ValidationSetBuilder: The ValidationSetBuilder instance.
|
|
163
|
-
|
|
164
|
-
Raises:
|
|
165
|
-
ValueError: If the lengths of categories and truths are inconsistent.
|
|
166
|
-
"""
|
|
167
|
-
payload = ClassifyPayload(
|
|
168
|
-
_t="ClassifyPayload", possibleCategories=categories, title=question
|
|
169
|
-
)
|
|
170
|
-
model_truth = AttachCategoryTruth(
|
|
171
|
-
correctCategories=truths, _t="AttachCategoryTruth"
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
self._rapid_parts.append(
|
|
175
|
-
ValidatioRapidParts(
|
|
176
|
-
question=question,
|
|
177
|
-
payload=payload,
|
|
178
|
-
truths=model_truth,
|
|
179
|
-
metadata=metadata,
|
|
180
|
-
randomCorrectProbability=len(truths) / len(categories),
|
|
181
|
-
asset=asset,
|
|
182
|
-
)
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
@deprecated("Use add_rapid instead")
|
|
186
|
-
def add_compare_rapid(
|
|
187
|
-
self,
|
|
188
|
-
asset: MultiAsset,
|
|
189
|
-
question: str,
|
|
190
|
-
truth: str,
|
|
191
|
-
metadata: list[Metadata] = [],
|
|
192
|
-
):
|
|
193
|
-
"""Add a compare rapid to the validation set.
|
|
194
|
-
|
|
195
|
-
Args:
|
|
196
|
-
asset (MultiAsset): The assets for the rapid.
|
|
197
|
-
question (str): The question for the rapid.
|
|
198
|
-
truth (str): The truth identifier for the rapid.
|
|
199
|
-
metadata (list[Metadata], optional): The metadata for the rapid. Defaults to an empty list.
|
|
200
|
-
|
|
201
|
-
Returns:
|
|
202
|
-
ValidationSetBuilder: The ValidationSetBuilder instance.
|
|
203
|
-
|
|
204
|
-
Raises:
|
|
205
|
-
ValueError: If the number of assets is not exactly two.
|
|
206
|
-
"""
|
|
207
|
-
self._add_compare_rapid(asset, question, truth, metadata)
|
|
208
|
-
|
|
209
|
-
return self
|
|
210
|
-
|
|
211
|
-
def _add_compare_rapid(
|
|
212
|
-
self,
|
|
213
|
-
asset: MultiAsset,
|
|
214
|
-
criteria: str,
|
|
215
|
-
truth: str,
|
|
216
|
-
metadata: list[Metadata] = [],
|
|
217
|
-
):
|
|
218
|
-
"""Add a compare rapid to the validation set.
|
|
219
|
-
|
|
220
|
-
Args:
|
|
221
|
-
asset (MultiAsset): The assets for the rapid.
|
|
222
|
-
criteria (str): The criteria for the comparison.
|
|
223
|
-
truth (str): The truth identifier for the rapid.
|
|
224
|
-
metadata (list[Metadata], optional): The metadata for the rapid. Defaults to an empty list.
|
|
225
|
-
|
|
226
|
-
Returns:
|
|
227
|
-
ValidationSetBuilder: The ValidationSetBuilder instance.
|
|
228
|
-
|
|
229
|
-
Raises:
|
|
230
|
-
ValueError: If the number of assets is not exactly two.
|
|
231
|
-
"""
|
|
232
|
-
payload = ComparePayload(_t="ComparePayload", criteria=criteria)
|
|
233
|
-
# take only last part of truth path
|
|
234
|
-
truth = os.path.basename(truth)
|
|
235
|
-
model_truth = CompareTruth(_t="CompareTruth", winnerId=truth)
|
|
236
|
-
|
|
237
|
-
if len(asset) != 2:
|
|
238
|
-
raise ValueError("Compare rapid requires exactly two media paths")
|
|
239
|
-
|
|
240
|
-
self._rapid_parts.append(
|
|
241
|
-
ValidatioRapidParts(
|
|
242
|
-
question=criteria,
|
|
243
|
-
payload=payload,
|
|
244
|
-
truths=model_truth,
|
|
245
|
-
metadata=metadata,
|
|
246
|
-
randomCorrectProbability=1 / len(asset),
|
|
247
|
-
asset=asset,
|
|
248
|
-
)
|
|
249
|
-
)
|
|
250
|
-
|
|
251
|
-
@deprecated("Use add_rapid instead")
|
|
252
|
-
def add_select_words_rapid(
|
|
253
|
-
self,
|
|
254
|
-
asset: MediaAsset | TextAsset,
|
|
255
|
-
question: str,
|
|
256
|
-
select_words: str,
|
|
257
|
-
truths: list[int],
|
|
258
|
-
strict_grading: bool | None = None,
|
|
259
|
-
metadata: list[Metadata] = [],
|
|
260
|
-
):
|
|
261
|
-
"""Add a select words rapid to the validation set.
|
|
262
|
-
|
|
263
|
-
Args:
|
|
264
|
-
asset (MediaAsset | TextAsset): The asset for the rapid.
|
|
265
|
-
question (str): The question for the rapid.
|
|
266
|
-
select words (list[str]): The select words for the rapid.
|
|
267
|
-
truths (list[int]): The list of indices of the true word selections.
|
|
268
|
-
strict_grading (bool | None, optional): The strict grading for the rapid. Defaults to None.
|
|
269
|
-
metadata (list[Metadata], optional): The metadata for the rapid.
|
|
270
|
-
|
|
271
|
-
Returns:
|
|
272
|
-
ValidationSetBuilder: The ValidationSetBuilder instance.
|
|
273
|
-
|
|
274
|
-
Raises:
|
|
275
|
-
ValueError: If a correct word is not found in the select words.
|
|
276
|
-
"""
|
|
277
|
-
self._add_select_words_rapid(asset, question, select_words, truths, strict_grading, metadata)
|
|
278
|
-
|
|
279
|
-
return self
|
|
280
|
-
|
|
281
|
-
def _add_select_words_rapid(
|
|
282
|
-
self,
|
|
283
|
-
asset: MediaAsset | TextAsset,
|
|
284
|
-
question: str,
|
|
285
|
-
select_words: str,
|
|
286
|
-
truths: list[int],
|
|
287
|
-
strict_grading: bool | None = None,
|
|
288
|
-
metadata: list[Metadata] = [],
|
|
289
|
-
):
|
|
290
|
-
"""Add a select words rapid to the validation set.
|
|
291
|
-
|
|
292
|
-
Args:
|
|
293
|
-
asset (MediaAsset | TextAsset): The asset for the rapid.
|
|
294
|
-
question (str): The question for the rapid.
|
|
295
|
-
select words (list[str]): The select words for the rapid.
|
|
296
|
-
truths (list[int]): The list of indices of the true word selections.
|
|
297
|
-
strict_grading (bool | None, optional): The strict grading for the rapid. Defaults to None.
|
|
298
|
-
metadata (list[Metadata], optional): The metadata for the rapid.
|
|
299
|
-
|
|
300
|
-
Returns:
|
|
301
|
-
ValidationSetBuilder: The ValidationSetBuilder instance.
|
|
302
|
-
|
|
303
|
-
Raises:
|
|
304
|
-
ValueError: If a correct word is not found in the select words.
|
|
305
|
-
"""
|
|
306
|
-
transcription_words = [
|
|
307
|
-
TranscriptionWord(word=word, wordIndex=i)
|
|
308
|
-
for i, word in enumerate(select_words.split())
|
|
309
|
-
]
|
|
310
|
-
|
|
311
|
-
true_words = []
|
|
312
|
-
for idx in truths:
|
|
313
|
-
if idx > len(transcription_words) - 1:
|
|
314
|
-
raise ValueError(f"Index {idx} is out of bounds")
|
|
315
|
-
true_words.append(transcription_words[idx])
|
|
316
|
-
|
|
317
|
-
payload = TranscriptionPayload(
|
|
318
|
-
_t="TranscriptionPayload", title=question, transcription=transcription_words
|
|
319
|
-
)
|
|
320
|
-
|
|
321
|
-
model_truth = TranscriptionTruth(
|
|
322
|
-
_t="TranscriptionTruth",
|
|
323
|
-
correctWords=true_words,
|
|
324
|
-
strictGrading=strict_grading,
|
|
325
|
-
)
|
|
326
|
-
|
|
327
|
-
self._rapid_parts.append(
|
|
328
|
-
ValidatioRapidParts(
|
|
329
|
-
question=question,
|
|
330
|
-
asset=asset,
|
|
331
|
-
payload=payload,
|
|
332
|
-
truths=model_truth,
|
|
333
|
-
metadata=metadata,
|
|
334
|
-
randomCorrectProbability = 1 / len(transcription_words),
|
|
335
|
-
)
|
|
336
|
-
)
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
from rapidata.service.openapi_service import OpenAPIService
|
|
2
|
-
from rapidata.rapidata_client.simple_builders.simple_classification_builders import ClassificationQuestionBuilder
|
|
3
|
-
from rapidata.rapidata_client.simple_builders.simple_compare_builders import CompareCriteriaBuilder
|
|
4
|
-
from rapidata.rapidata_client.simple_builders.simple_free_text_builders import FreeTextQuestionBuilder
|
|
5
|
-
from rapidata.rapidata_client.simple_builders.simple_select_words_builders import SelectWordsInstructionBuilder
|
|
6
|
-
from rapidata.rapidata_client.order.rapidata_order_builder import RapidataOrderBuilder
|
|
7
|
-
|
|
8
|
-
class BaseOrderBuilder():
|
|
9
|
-
def __init__(self, openapi_service: OpenAPIService):
|
|
10
|
-
self.openapi_service = openapi_service
|
|
11
|
-
|
|
12
|
-
def classify_order(self, name: str):
|
|
13
|
-
return ClassificationQuestionBuilder(name, self.openapi_service)
|
|
14
|
-
|
|
15
|
-
def compare_order(self, name: str):
|
|
16
|
-
return CompareCriteriaBuilder(name, self.openapi_service)
|
|
17
|
-
|
|
18
|
-
def free_text_order(self, name: str):
|
|
19
|
-
return FreeTextQuestionBuilder(name, self.openapi_service)
|
|
20
|
-
|
|
21
|
-
def select_words_order(self, name: str):
|
|
22
|
-
return SelectWordsInstructionBuilder(name, self.openapi_service)
|
|
23
|
-
|
|
24
|
-
def advanced_order(self, name: str):
|
|
25
|
-
return RapidataOrderBuilder(name, self.openapi_service)
|