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,166 +0,0 @@
|
|
|
1
|
-
from rapidata.rapidata_client.assets import MediaAsset, TextAsset
|
|
2
|
-
from rapidata.rapidata_client.metadata import PromptMetadata
|
|
3
|
-
from rapidata.rapidata_client.dataset.rapid_builders.rapids import ClassificationRapid
|
|
4
|
-
|
|
5
|
-
class ClassifyRapidBuilder:
|
|
6
|
-
"""Final builder class for classification rapid.
|
|
7
|
-
|
|
8
|
-
This class handles the final construction of a classification rapid with all required parameters.
|
|
9
|
-
"""
|
|
10
|
-
def __init__(self, question: str, options: list[str], truths: list[str], asset: MediaAsset | TextAsset):
|
|
11
|
-
self._question = question
|
|
12
|
-
self._options = options
|
|
13
|
-
self._truths = truths
|
|
14
|
-
self._asset = asset
|
|
15
|
-
self._metadata = []
|
|
16
|
-
|
|
17
|
-
def prompt(self, prompt: str):
|
|
18
|
-
"""Add a prompt to provide additional context for the classification task.
|
|
19
|
-
|
|
20
|
-
Args:
|
|
21
|
-
prompt (str): Additional instructions or context
|
|
22
|
-
|
|
23
|
-
Returns:
|
|
24
|
-
ClassifyRapidBuilder: The builder instance for method chaining
|
|
25
|
-
"""
|
|
26
|
-
self._metadata.append(PromptMetadata(prompt))
|
|
27
|
-
return self
|
|
28
|
-
|
|
29
|
-
def build(self):
|
|
30
|
-
"""Constructs and returns the final classification rapid.
|
|
31
|
-
|
|
32
|
-
Returns:
|
|
33
|
-
ClassificationRapid: The constructed classification rapid
|
|
34
|
-
"""
|
|
35
|
-
return ClassificationRapid(
|
|
36
|
-
question=self._question,
|
|
37
|
-
options=self._options,
|
|
38
|
-
truths=self._truths,
|
|
39
|
-
asset=self._asset,
|
|
40
|
-
metadata=self._metadata
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
class ClassifyRapidTruthBuilder:
|
|
44
|
-
"""Builder class for the truths of the classification rapid.
|
|
45
|
-
|
|
46
|
-
This adds the truths to the classification rapid.
|
|
47
|
-
"""
|
|
48
|
-
def __init__(self, question: str, options: list[str], asset: MediaAsset | TextAsset):
|
|
49
|
-
self._question = question
|
|
50
|
-
self._options = options
|
|
51
|
-
self._asset = asset
|
|
52
|
-
self._truths = None
|
|
53
|
-
|
|
54
|
-
def truths(self, truths: list[str]):
|
|
55
|
-
"""Set the truths for the classification rapid.
|
|
56
|
-
|
|
57
|
-
Args:
|
|
58
|
-
truths (list[str]): The correct answers for the classification task"""
|
|
59
|
-
|
|
60
|
-
if not isinstance(truths, list) or not all(isinstance(truth, str) for truth in truths):
|
|
61
|
-
raise ValueError("Truths must be a list of strings")
|
|
62
|
-
|
|
63
|
-
if not all(truth in self._options for truth in truths):
|
|
64
|
-
raise ValueError("Truths must be one of the selectable options")
|
|
65
|
-
|
|
66
|
-
self._truths = truths
|
|
67
|
-
return self._build()
|
|
68
|
-
|
|
69
|
-
def _build(self):
|
|
70
|
-
if self._truths is None:
|
|
71
|
-
raise ValueError("Truths are required")
|
|
72
|
-
return ClassifyRapidBuilder(
|
|
73
|
-
question=self._question,
|
|
74
|
-
options=self._options,
|
|
75
|
-
asset=self._asset,
|
|
76
|
-
truths=self._truths,
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
class ClassifyRapidMediaBuilder:
|
|
80
|
-
"""Builder class for the media asset of the classification rapid.
|
|
81
|
-
|
|
82
|
-
This class adds the media asset to the classification rapid.
|
|
83
|
-
"""
|
|
84
|
-
def __init__(self, question: str, options: list[str]):
|
|
85
|
-
self._question = question
|
|
86
|
-
self._options = options
|
|
87
|
-
self._asset: MediaAsset | TextAsset | None = None
|
|
88
|
-
|
|
89
|
-
def media(self, media: str):
|
|
90
|
-
"""Set the media asset for the classification rapid.
|
|
91
|
-
|
|
92
|
-
Args:
|
|
93
|
-
media (str): A local file path or an image URL. The image will be displayed with the classification task"""
|
|
94
|
-
self._asset = MediaAsset(media)
|
|
95
|
-
|
|
96
|
-
return self._build()
|
|
97
|
-
|
|
98
|
-
def text(self, text: str):
|
|
99
|
-
"""Set the text asset for the classification rapid.
|
|
100
|
-
|
|
101
|
-
Args:
|
|
102
|
-
text (str): The text to be displayed with the classification task"""
|
|
103
|
-
self._asset = TextAsset(text)
|
|
104
|
-
|
|
105
|
-
return self._build()
|
|
106
|
-
|
|
107
|
-
def _build(self):
|
|
108
|
-
if self._asset is None:
|
|
109
|
-
raise ValueError("Assets are required")
|
|
110
|
-
|
|
111
|
-
return ClassifyRapidTruthBuilder(
|
|
112
|
-
question=self._question,
|
|
113
|
-
options=self._options,
|
|
114
|
-
asset=self._asset,
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
class ClassifyRapidOptionsBuilder:
|
|
118
|
-
def __init__(self, question: str):
|
|
119
|
-
self._question = question
|
|
120
|
-
self._options = None
|
|
121
|
-
|
|
122
|
-
def options(self, options: list[str]):
|
|
123
|
-
"""Set the options for the classification rapid.
|
|
124
|
-
|
|
125
|
-
Args:
|
|
126
|
-
options (list[str]): The selectable options for the classification task"""
|
|
127
|
-
|
|
128
|
-
if not isinstance(options, list) or not all(isinstance(option, str) for option in options):
|
|
129
|
-
raise ValueError("Options must be a list of strings")
|
|
130
|
-
|
|
131
|
-
self._options = options
|
|
132
|
-
return self._build()
|
|
133
|
-
|
|
134
|
-
def _build(self):
|
|
135
|
-
if self._options is None:
|
|
136
|
-
raise ValueError("Options are required")
|
|
137
|
-
|
|
138
|
-
return ClassifyRapidMediaBuilder(
|
|
139
|
-
question=self._question,
|
|
140
|
-
options=self._options,
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
class ClassifyRapidQuestionBuilder:
|
|
145
|
-
def __init__(self):
|
|
146
|
-
self._question = None
|
|
147
|
-
|
|
148
|
-
def question(self, question: str):
|
|
149
|
-
"""Set the question for the classification rapid.
|
|
150
|
-
|
|
151
|
-
Args:
|
|
152
|
-
question (str): The question to be answered by the classification task"""
|
|
153
|
-
|
|
154
|
-
if not isinstance(question, str):
|
|
155
|
-
raise ValueError("Question must be a string")
|
|
156
|
-
|
|
157
|
-
self._question = question
|
|
158
|
-
return self._build()
|
|
159
|
-
|
|
160
|
-
def _build(self):
|
|
161
|
-
if self._question is None:
|
|
162
|
-
raise ValueError("Question is required")
|
|
163
|
-
|
|
164
|
-
return ClassifyRapidOptionsBuilder(
|
|
165
|
-
question=self._question,
|
|
166
|
-
)
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
from rapidata.rapidata_client.assets import MultiAsset, TextAsset, MediaAsset
|
|
2
|
-
from rapidata.rapidata_client.metadata import PromptMetadata
|
|
3
|
-
from rapidata.rapidata_client.dataset.rapid_builders.rapids import CompareRapid
|
|
4
|
-
import re
|
|
5
|
-
|
|
6
|
-
class CompareRapidBuilder:
|
|
7
|
-
"""Final builder class for comparison rapid.
|
|
8
|
-
|
|
9
|
-
This class handles the final construction of a comparison rapid with all required parameters.
|
|
10
|
-
"""
|
|
11
|
-
def __init__(self, criteria: str, truth: str, asset: MultiAsset):
|
|
12
|
-
"""Initialize the comparison rapid builder.
|
|
13
|
-
|
|
14
|
-
Args:
|
|
15
|
-
criteria (str): The criteria for comparison
|
|
16
|
-
truth (str): The correct answer
|
|
17
|
-
asset (MultiAsset): Collection of assets to be compared
|
|
18
|
-
"""
|
|
19
|
-
self._criteria = criteria
|
|
20
|
-
self._truth = truth
|
|
21
|
-
self._asset = asset
|
|
22
|
-
self._metadata = []
|
|
23
|
-
|
|
24
|
-
def prompt(self, prompt: str):
|
|
25
|
-
"""Add a prompt to provide additional context for the comparison.
|
|
26
|
-
|
|
27
|
-
Args:
|
|
28
|
-
prompt (str): Additional instructions or context
|
|
29
|
-
|
|
30
|
-
Returns:
|
|
31
|
-
CompareRapidBuilder: The builder instance for method chaining
|
|
32
|
-
"""
|
|
33
|
-
self._metadata.append(PromptMetadata(prompt))
|
|
34
|
-
return self
|
|
35
|
-
|
|
36
|
-
def build(self):
|
|
37
|
-
"""Constructs and returns the final comparison rapid.
|
|
38
|
-
|
|
39
|
-
Returns:
|
|
40
|
-
CompareRapid: The constructed comparison rapid
|
|
41
|
-
"""
|
|
42
|
-
return CompareRapid(
|
|
43
|
-
criteria=self._criteria,
|
|
44
|
-
asset=self._asset,
|
|
45
|
-
truth=self._truth,
|
|
46
|
-
metadata=self._metadata
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
class CompareRapidTruthBuilder:
|
|
50
|
-
"""Builder class for the truth of the comparison rapid.
|
|
51
|
-
|
|
52
|
-
This adds the truth to the comparison rapid.
|
|
53
|
-
"""
|
|
54
|
-
def __init__(self, criteria: str, asset: MultiAsset):
|
|
55
|
-
self._criteria = criteria
|
|
56
|
-
self._asset = asset
|
|
57
|
-
self._truth = None
|
|
58
|
-
|
|
59
|
-
def truth(self, truth: str):
|
|
60
|
-
"""Set the truth for the comparison rapid.
|
|
61
|
-
|
|
62
|
-
Args:
|
|
63
|
-
truth (str): The correct answer for the comparison task. Is the string of the correct media/text asset"""
|
|
64
|
-
|
|
65
|
-
if not isinstance(truth, str):
|
|
66
|
-
raise ValueError("Truth must be a string.")
|
|
67
|
-
|
|
68
|
-
self._truth = MediaAsset(truth).name
|
|
69
|
-
|
|
70
|
-
return self._build()
|
|
71
|
-
|
|
72
|
-
def _build(self):
|
|
73
|
-
if self._truth is None:
|
|
74
|
-
raise ValueError("Truth is required")
|
|
75
|
-
|
|
76
|
-
return CompareRapidBuilder(
|
|
77
|
-
criteria=self._criteria,
|
|
78
|
-
asset=self._asset,
|
|
79
|
-
truth=self._truth,
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
class CompareRapidAssetBuilder:
|
|
83
|
-
"""Builder class for the asset of the comparison rapid.
|
|
84
|
-
|
|
85
|
-
This adds the asset to the comparison rapid.
|
|
86
|
-
"""
|
|
87
|
-
def __init__(self, criteria: str):
|
|
88
|
-
self._criteria = criteria
|
|
89
|
-
self._asset: MultiAsset | None = None
|
|
90
|
-
|
|
91
|
-
def media(self, medias: list[str]):
|
|
92
|
-
"""Set the media assets for the comparison rapid.
|
|
93
|
-
|
|
94
|
-
Args:
|
|
95
|
-
medias (list[str]): The local file paths or links of the media assets to be compared"""
|
|
96
|
-
|
|
97
|
-
media_assets = [MediaAsset(media) for media in medias]
|
|
98
|
-
self._asset = MultiAsset(media_assets)
|
|
99
|
-
return self._build()
|
|
100
|
-
|
|
101
|
-
def text(self, texts: list[str]):
|
|
102
|
-
"""Set the text assets for the comparison rapid.
|
|
103
|
-
|
|
104
|
-
Args:
|
|
105
|
-
texts (list[str]): The texts to be compared"""
|
|
106
|
-
|
|
107
|
-
text_assets = [TextAsset(text) for text in texts]
|
|
108
|
-
self._asset = MultiAsset(text_assets)
|
|
109
|
-
return self._build()
|
|
110
|
-
|
|
111
|
-
def _build(self):
|
|
112
|
-
if self._asset is None:
|
|
113
|
-
raise ValueError("Asset is required")
|
|
114
|
-
|
|
115
|
-
return CompareRapidTruthBuilder(
|
|
116
|
-
criteria=self._criteria,
|
|
117
|
-
asset=self._asset,
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
class CompareRapidCriteriaBuilder:
|
|
121
|
-
"""Builder class for the criteria of the comparison rapid.
|
|
122
|
-
|
|
123
|
-
This adds the criteria to the comparison rapid."""
|
|
124
|
-
def __init__(self):
|
|
125
|
-
self._criteria = None
|
|
126
|
-
|
|
127
|
-
def criteria(self, criteria: str):
|
|
128
|
-
"""Set the criteria for the comparison rapid.
|
|
129
|
-
|
|
130
|
-
Args:
|
|
131
|
-
criteria (str): The criteria for comparison"""
|
|
132
|
-
|
|
133
|
-
if not isinstance(criteria, str):
|
|
134
|
-
raise ValueError("Criteria must be a string")
|
|
135
|
-
|
|
136
|
-
self._criteria = criteria
|
|
137
|
-
return self._build()
|
|
138
|
-
|
|
139
|
-
def _build(self):
|
|
140
|
-
if self._criteria is None:
|
|
141
|
-
raise ValueError("Criteria is required")
|
|
142
|
-
|
|
143
|
-
return CompareRapidAssetBuilder(
|
|
144
|
-
criteria=self._criteria,
|
|
145
|
-
)
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
from rapidata.rapidata_client.assets import MediaAsset, TextAsset, MultiAsset
|
|
2
|
-
from rapidata.rapidata_client.metadata import Metadata
|
|
3
|
-
|
|
4
|
-
class Rapid:
|
|
5
|
-
pass
|
|
6
|
-
|
|
7
|
-
class ClassificationRapid(Rapid):
|
|
8
|
-
"""A classification rapid. This represents the question, options, truths, asset and metadata that will be given to the labeler."""
|
|
9
|
-
def __init__(self, question: str, options: list[str], truths: list[str], asset: MediaAsset | TextAsset, metadata: list[Metadata]):
|
|
10
|
-
self.question = question
|
|
11
|
-
self.options = options
|
|
12
|
-
self.truths = truths
|
|
13
|
-
self.asset = asset
|
|
14
|
-
self.metadata = metadata
|
|
15
|
-
|
|
16
|
-
class CompareRapid(Rapid):
|
|
17
|
-
"""A comparison rapid. This represents the criteria, asset, truth and metadata that will be given to the labeler."""
|
|
18
|
-
def __init__(self, criteria: str, truth: str, asset: MultiAsset, metadata: list[Metadata]):
|
|
19
|
-
self.criteria = criteria
|
|
20
|
-
self.asset = asset
|
|
21
|
-
self.truth = truth
|
|
22
|
-
self.metadata = metadata
|
|
23
|
-
|
|
24
|
-
class SelectWordsRapid(Rapid):
|
|
25
|
-
"""A transcription rapid. This represents the instruction, truths, asset, transcription and strict grading that will be given to the labeler."""
|
|
26
|
-
def __init__(self, instruction: str, truths: list[int], asset: MediaAsset, text: str, strict_grading: bool):
|
|
27
|
-
"""The text will be split up by spaces to be selected by the labeler."""
|
|
28
|
-
self.instruction = instruction
|
|
29
|
-
self.truths = truths
|
|
30
|
-
self.asset = asset
|
|
31
|
-
self.text = text
|
|
32
|
-
self.strict_grading = strict_grading
|
|
33
|
-
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
from rapidata.rapidata_client.assets import MediaAsset
|
|
2
|
-
from rapidata.rapidata_client.dataset.rapid_builders.rapids import SelectWordsRapid
|
|
3
|
-
|
|
4
|
-
class SelectWordsRapidBuilder:
|
|
5
|
-
"""Final builder class for rapid.
|
|
6
|
-
|
|
7
|
-
This class handles the final construction of a rapid with all required parameters.
|
|
8
|
-
"""
|
|
9
|
-
def __init__(self, instruction: str, truths: list[int], asset: MediaAsset, text: str):
|
|
10
|
-
self._instruction = instruction
|
|
11
|
-
self._truths = truths
|
|
12
|
-
self._asset = asset
|
|
13
|
-
self._text = text
|
|
14
|
-
self._strict_grading = True
|
|
15
|
-
|
|
16
|
-
def strict_grading(self, strict_grading: bool = True):
|
|
17
|
-
"""Set whether to use strict grading for the select words.
|
|
18
|
-
Strict grading true: In order to be correct, you must select all of the right words
|
|
19
|
-
Strict grading false: In order to be correct, you must select at least one right word
|
|
20
|
-
In both cases it will be incorrect if you select any wrong words
|
|
21
|
-
|
|
22
|
-
Args:
|
|
23
|
-
strict_grading (bool): Whether to use strict grading. Defaults to True."""
|
|
24
|
-
self._strict_grading = strict_grading
|
|
25
|
-
return self
|
|
26
|
-
|
|
27
|
-
def build(self):
|
|
28
|
-
"""Constructs and returns the final rapid."""
|
|
29
|
-
return SelectWordsRapid(
|
|
30
|
-
instruction=self._instruction,
|
|
31
|
-
truths=self._truths,
|
|
32
|
-
asset=self._asset,
|
|
33
|
-
text=self._text,
|
|
34
|
-
strict_grading=self._strict_grading
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
class SelectWordsRapidTruthsBuilder:
|
|
38
|
-
"""Builder class for the truths of the rapid.
|
|
39
|
-
|
|
40
|
-
This adds the truths to the rapid.
|
|
41
|
-
"""
|
|
42
|
-
def __init__(self, instruction: str, media: MediaAsset, text: str):
|
|
43
|
-
self._instruction = instruction
|
|
44
|
-
self._media = media
|
|
45
|
-
self._text = text
|
|
46
|
-
self._truths = None
|
|
47
|
-
|
|
48
|
-
def truths(self, truths: list[int]):
|
|
49
|
-
"""Set the truths for the rapid.
|
|
50
|
-
|
|
51
|
-
Args:
|
|
52
|
-
truths (list[int]): The correct answers for the task. \
|
|
53
|
-
Each integer represents the index of the correct word in the text."""
|
|
54
|
-
|
|
55
|
-
if not isinstance(truths, list) or not all(isinstance(truth, int) for truth in truths):
|
|
56
|
-
raise ValueError("Truths must be a list of integers")
|
|
57
|
-
|
|
58
|
-
self._truths = truths
|
|
59
|
-
return self._build()
|
|
60
|
-
|
|
61
|
-
def _build(self):
|
|
62
|
-
if self._truths is None:
|
|
63
|
-
raise ValueError("Truths are required")
|
|
64
|
-
|
|
65
|
-
return SelectWordsRapidBuilder(
|
|
66
|
-
instruction=self._instruction,
|
|
67
|
-
truths=self._truths,
|
|
68
|
-
asset=self._media,
|
|
69
|
-
text=self._text
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
class SelectWordsRapidAssetBuilder:
|
|
73
|
-
"""Builder class for the asset of the rapid.
|
|
74
|
-
|
|
75
|
-
This adds the asset to the rapid.
|
|
76
|
-
"""
|
|
77
|
-
def __init__(self, instruction: str):
|
|
78
|
-
self._instruction = instruction
|
|
79
|
-
|
|
80
|
-
def media(self, media: str, text: str):
|
|
81
|
-
"""Set the media asset for the rapid.
|
|
82
|
-
|
|
83
|
-
Args:
|
|
84
|
-
media (str): The local path (image, video, audio) or URL (image) of the media asset.
|
|
85
|
-
text (str): The text will be split up by spaces and the labeler will be able to select the words"""
|
|
86
|
-
|
|
87
|
-
self._asset = MediaAsset(media)
|
|
88
|
-
self._text = text
|
|
89
|
-
|
|
90
|
-
return self._build()
|
|
91
|
-
|
|
92
|
-
def _build(self):
|
|
93
|
-
if not self._asset:
|
|
94
|
-
raise ValueError("Media is required")
|
|
95
|
-
|
|
96
|
-
return SelectWordsRapidTruthsBuilder(
|
|
97
|
-
instruction=self._instruction,
|
|
98
|
-
media=self._asset,
|
|
99
|
-
text=self._text
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
class SelectWordsRapidInstructionBuilder:
|
|
103
|
-
def __init__(self):
|
|
104
|
-
self._instruction = None
|
|
105
|
-
|
|
106
|
-
def instruction(self, instruction: str):
|
|
107
|
-
"""Set the instruction for the rapid.
|
|
108
|
-
|
|
109
|
-
Args:
|
|
110
|
-
instruction (str): The instruction for the task"""
|
|
111
|
-
|
|
112
|
-
if not isinstance(instruction, str):
|
|
113
|
-
raise ValueError("Instruction must be a string")
|
|
114
|
-
|
|
115
|
-
self._instruction = instruction
|
|
116
|
-
return self._build()
|
|
117
|
-
|
|
118
|
-
def _build(self):
|
|
119
|
-
if self._instruction is None:
|
|
120
|
-
raise ValueError("Instruction is required")
|
|
121
|
-
|
|
122
|
-
return SelectWordsRapidAssetBuilder(
|
|
123
|
-
instruction=self._instruction,
|
|
124
|
-
)
|