rapidata 1.8.3__py3-none-any.whl → 1.10.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 +2 -2
- rapidata/api_client/models/rapid_answer.py +3 -1
- rapidata/rapidata_client/__init__.py +2 -2
- rapidata/rapidata_client/assets/media_asset.py +38 -29
- rapidata/rapidata_client/dataset/rapid_builders/__init__.py +1 -1
- rapidata/rapidata_client/dataset/rapid_builders/base_rapid_builder.py +5 -5
- rapidata/rapidata_client/dataset/rapid_builders/rapids.py +7 -6
- rapidata/rapidata_client/dataset/rapid_builders/{transcription_rapid_builders.py → select_words_rapid_builders.py} +35 -43
- rapidata/rapidata_client/dataset/rapidata_validation_set.py +6 -0
- rapidata/rapidata_client/dataset/validation_set_builder.py +28 -16
- rapidata/rapidata_client/metadata/__init__.py +1 -1
- rapidata/rapidata_client/metadata/{transcription_metadata.py → select_words_metadata.py} +4 -4
- rapidata/rapidata_client/order/order_builder.py +25 -0
- rapidata/rapidata_client/order/rapidata_order.py +1 -1
- rapidata/rapidata_client/order/rapidata_order_builder.py +1 -1
- rapidata/rapidata_client/rapidata_client.py +32 -9
- rapidata/rapidata_client/selection/capped_selection.py +1 -1
- rapidata/rapidata_client/simple_builders/simple_classification_builders.py +35 -9
- rapidata/rapidata_client/simple_builders/simple_compare_builders.py +26 -9
- rapidata/rapidata_client/simple_builders/simple_free_text_builders.py +13 -1
- rapidata/rapidata_client/simple_builders/{simple_transcription_builders.py → simple_select_words_builders.py} +48 -46
- rapidata/rapidata_client/workflow/__init__.py +1 -1
- rapidata/rapidata_client/workflow/{transcription_workflow.py → select_words_workflow.py} +7 -7
- {rapidata-1.8.3.dist-info → rapidata-1.10.0.dist-info}/METADATA +1 -1
- {rapidata-1.8.3.dist-info → rapidata-1.10.0.dist-info}/RECORD +27 -26
- {rapidata-1.8.3.dist-info → rapidata-1.10.0.dist-info}/LICENSE +0 -0
- {rapidata-1.8.3.dist-info → rapidata-1.10.0.dist-info}/WHEEL +0 -0
|
@@ -5,10 +5,12 @@ from rapidata.service.openapi_service import OpenAPIService
|
|
|
5
5
|
from rapidata.rapidata_client.order.rapidata_order import RapidataOrder
|
|
6
6
|
from rapidata.rapidata_client.dataset.rapidata_dataset import RapidataDataset
|
|
7
7
|
|
|
8
|
+
from rapidata.rapidata_client.order.order_builder import BaseOrderBuilder
|
|
9
|
+
|
|
8
10
|
from rapidata.rapidata_client.simple_builders.simple_classification_builders import ClassificationQuestionBuilder
|
|
9
11
|
from rapidata.rapidata_client.simple_builders.simple_compare_builders import CompareCriteriaBuilder
|
|
10
12
|
from rapidata.rapidata_client.simple_builders.simple_free_text_builders import FreeTextQuestionBuilder
|
|
11
|
-
from rapidata.rapidata_client.simple_builders.
|
|
13
|
+
from rapidata.rapidata_client.simple_builders.simple_select_words_builders import SelectWordsInstructionBuilder
|
|
12
14
|
|
|
13
15
|
from rapidata.rapidata_client.dataset.rapid_builders import BaseRapidBuilder
|
|
14
16
|
|
|
@@ -28,8 +30,6 @@ from deprecated import deprecated
|
|
|
28
30
|
|
|
29
31
|
class RapidataClient:
|
|
30
32
|
"""The Rapidata client is the main entry point for interacting with the Rapidata API. It allows you to create orders and validation sets."""
|
|
31
|
-
|
|
32
|
-
rapid_builder = BaseRapidBuilder()
|
|
33
33
|
|
|
34
34
|
def __init__(
|
|
35
35
|
self,
|
|
@@ -53,8 +53,12 @@ class RapidataClient:
|
|
|
53
53
|
oauth_scope=oauth_scope,
|
|
54
54
|
cert_path=cert_path
|
|
55
55
|
)
|
|
56
|
+
|
|
57
|
+
self.rapid_builder = BaseRapidBuilder()
|
|
58
|
+
|
|
59
|
+
self.order_builder = BaseOrderBuilder(openapi_service=self.openapi_service)
|
|
56
60
|
|
|
57
|
-
@deprecated("Use the
|
|
61
|
+
@deprecated("Use the order_builder instead.")
|
|
58
62
|
def new_order(self, name: str) -> RapidataOrderBuilder:
|
|
59
63
|
"""Create a new order using a RapidataOrderBuilder instance.
|
|
60
64
|
|
|
@@ -64,7 +68,22 @@ class RapidataClient:
|
|
|
64
68
|
Returns:
|
|
65
69
|
RapidataOrderBuilder: A RapidataOrderBuilder instance.
|
|
66
70
|
"""
|
|
67
|
-
return
|
|
71
|
+
return self.new_advanced_order(name)
|
|
72
|
+
|
|
73
|
+
@deprecated("Use the order_builder instead.")
|
|
74
|
+
def new_advanced_order(self, name: str) -> RapidataOrderBuilder:
|
|
75
|
+
"""Create a new order using a RapidataOrderBuilder instance.
|
|
76
|
+
This method is intended for creating orders with complex requirements that can not be fulfilled with the specific builders.
|
|
77
|
+
For any other order, it is recommended to use the specific builder methods.
|
|
78
|
+
example: create_classify_order, create_compare_order, create_free_text_order, create_select_words_order
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
name (str): The name of the order.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
RapidataOrderBuilder: A RapidataOrderBuilder instance.
|
|
85
|
+
"""
|
|
86
|
+
return RapidataOrderBuilder(name=name, openapi_service=self.openapi_service)
|
|
68
87
|
|
|
69
88
|
def new_validation_set(self, name: str) -> ValidationSetBuilder:
|
|
70
89
|
"""Create a new validation set using a ValidationDatasetBuilder instance.
|
|
@@ -161,6 +180,7 @@ class RapidataClient:
|
|
|
161
180
|
orders = [self.get_validation_set(validation_set.id) for validation_set in validation_page_result.items] # type: ignore # will be fixed with the next backend deployment
|
|
162
181
|
return orders
|
|
163
182
|
|
|
183
|
+
@deprecated("Use the order_builder instead.")
|
|
164
184
|
def create_classify_order(self, name: str) -> ClassificationQuestionBuilder:
|
|
165
185
|
"""Create a new classification order where people are asked to classify an image.
|
|
166
186
|
|
|
@@ -172,6 +192,7 @@ class RapidataClient:
|
|
|
172
192
|
"""
|
|
173
193
|
return ClassificationQuestionBuilder(name=name, openapi_service=self.openapi_service)
|
|
174
194
|
|
|
195
|
+
@deprecated("Use the order_builder instead.")
|
|
175
196
|
def create_compare_order(self, name: str) -> CompareCriteriaBuilder:
|
|
176
197
|
"""Create a new comparison order where people are asked to compare two images.
|
|
177
198
|
|
|
@@ -183,6 +204,7 @@ class RapidataClient:
|
|
|
183
204
|
"""
|
|
184
205
|
return CompareCriteriaBuilder(name=name, openapi_service=self.openapi_service)
|
|
185
206
|
|
|
207
|
+
@deprecated("Use the order_builder instead.")
|
|
186
208
|
def create_free_text_order(self, name: str) -> FreeTextQuestionBuilder:
|
|
187
209
|
"""Create a new free text order where people are asked to provide a free text answer.
|
|
188
210
|
|
|
@@ -194,14 +216,15 @@ class RapidataClient:
|
|
|
194
216
|
"""
|
|
195
217
|
return FreeTextQuestionBuilder(name=name, openapi_service=self.openapi_service)
|
|
196
218
|
|
|
197
|
-
|
|
198
|
-
|
|
219
|
+
@deprecated("Use the order_builder instead.")
|
|
220
|
+
def create_select_words_order(self, name: str) -> SelectWordsInstructionBuilder:
|
|
221
|
+
"""Create a new select words order where people are asked to transcribe an audio file.
|
|
199
222
|
|
|
200
223
|
Args:
|
|
201
224
|
name (str): The name of the order.
|
|
202
225
|
|
|
203
226
|
Returns:
|
|
204
|
-
|
|
227
|
+
SelectWordsInstructionBuilder: A SelectWordsInstructionBuilder instance.
|
|
205
228
|
"""
|
|
206
|
-
return
|
|
229
|
+
return SelectWordsInstructionBuilder(name=name, openapi_service=self.openapi_service)
|
|
207
230
|
|
|
@@ -28,7 +28,7 @@ class ClassificationOrderBuilder:
|
|
|
28
28
|
self._options = options
|
|
29
29
|
self._media_assets = media_assets
|
|
30
30
|
self._responses_required = 10
|
|
31
|
-
self.
|
|
31
|
+
self._confidence_threshold = None
|
|
32
32
|
self._metadata = None
|
|
33
33
|
self._validation_set_id = None
|
|
34
34
|
self._filters: list[Filter] = []
|
|
@@ -54,12 +54,16 @@ class ClassificationOrderBuilder:
|
|
|
54
54
|
|
|
55
55
|
def responses(self, responses_required: int) -> 'ClassificationOrderBuilder':
|
|
56
56
|
"""Set the number of responses required per datapoint for the classification order. Will default to 10."""
|
|
57
|
+
if responses_required < 1:
|
|
58
|
+
raise ValueError("Responses required must be at least 1")
|
|
59
|
+
|
|
57
60
|
self._responses_required = responses_required
|
|
58
61
|
return self
|
|
59
62
|
|
|
60
|
-
def
|
|
61
|
-
"""Set the
|
|
62
|
-
|
|
63
|
+
def confidence_threshold(self, confidence_threshold: float) -> 'ClassificationOrderBuilder':
|
|
64
|
+
"""Set the confidence threshold for early stopping.
|
|
65
|
+
That means that the order will either stop at the number of responses or when the confidence threshold is reached, whatever comes first."""
|
|
66
|
+
self._confidence_threshold = confidence_threshold
|
|
63
67
|
return self
|
|
64
68
|
|
|
65
69
|
def validation_set(self, validation_set_id: str) -> 'ClassificationOrderBuilder':
|
|
@@ -104,14 +108,27 @@ class ClassificationOrderBuilder:
|
|
|
104
108
|
|
|
105
109
|
return self
|
|
106
110
|
|
|
107
|
-
@deprecated("Use .
|
|
111
|
+
@deprecated("Use .submit instead.")
|
|
108
112
|
def create(self, submit: bool = True, max_upload_workers: int = 10) -> 'RapidataOrder':
|
|
109
113
|
"""Create the classification order."""
|
|
110
|
-
return self.
|
|
111
|
-
|
|
114
|
+
return self.submit(submit=submit, disable_link=False)
|
|
115
|
+
|
|
116
|
+
@deprecated("Use .submit instead.")
|
|
112
117
|
def run(self, submit: bool = True, disable_link: bool = False) -> 'RapidataOrder':
|
|
113
118
|
"""Run the classification order.
|
|
114
119
|
|
|
120
|
+
Args:
|
|
121
|
+
submit (bool): Whether to submit the order. Defaults to True. \
|
|
122
|
+
Set this to False if you first want to see the order on your dashboard before running it.
|
|
123
|
+
disable_link (bool): Whether to disable the printing of the link to the order. Defaults to False.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
RapidataOrder: The created classification order."""
|
|
127
|
+
return self.submit(submit=submit, disable_link=disable_link)
|
|
128
|
+
|
|
129
|
+
def submit(self, submit: bool = True, disable_link: bool = False) -> 'RapidataOrder':
|
|
130
|
+
"""Submit the classification order to be labeled.
|
|
131
|
+
|
|
115
132
|
Args:
|
|
116
133
|
submit (bool): Whether to submit the order. Defaults to True. \
|
|
117
134
|
Set this to False if you first want to see the order on your dashboard before running it.
|
|
@@ -120,10 +137,10 @@ class ClassificationOrderBuilder:
|
|
|
120
137
|
Returns:
|
|
121
138
|
RapidataOrder: The created classification order."""
|
|
122
139
|
|
|
123
|
-
if self.
|
|
140
|
+
if self._confidence_threshold:
|
|
124
141
|
referee = EarlyStoppingReferee(
|
|
125
142
|
max_vote_count=self._responses_required,
|
|
126
|
-
threshold=self.
|
|
143
|
+
threshold=self._confidence_threshold
|
|
127
144
|
)
|
|
128
145
|
|
|
129
146
|
else:
|
|
@@ -219,6 +236,15 @@ class ClassificationOptionsBuilder:
|
|
|
219
236
|
|
|
220
237
|
def options(self, options: list[str]) -> ClassificationMediaBuilder:
|
|
221
238
|
"""Set the answer options for the classification order."""
|
|
239
|
+
if not isinstance(options, list) or not all(isinstance(option, str) for option in options):
|
|
240
|
+
raise ValueError("Options must be a list of strings")
|
|
241
|
+
|
|
242
|
+
if len(options) < 2:
|
|
243
|
+
raise ValueError("At least two options are required")
|
|
244
|
+
|
|
245
|
+
if len(options) > 8:
|
|
246
|
+
raise ValueError("Maximum of 8 options allowed")
|
|
247
|
+
|
|
222
248
|
self._options = options
|
|
223
249
|
return self._build()
|
|
224
250
|
|
|
@@ -23,13 +23,16 @@ class CompareOrderBuilder:
|
|
|
23
23
|
self._responses_required = 10
|
|
24
24
|
self._metadata = None
|
|
25
25
|
self._validation_set_id = None
|
|
26
|
-
self.
|
|
26
|
+
self._confidence_threshold = None
|
|
27
27
|
self._filters: list[Filter] = []
|
|
28
28
|
self._settings = Settings()
|
|
29
29
|
self._time_effort = time_effort
|
|
30
30
|
|
|
31
31
|
def responses(self, responses_required: int) -> 'CompareOrderBuilder':
|
|
32
|
-
"""Set the number of resoonses required per matchup/pairing for the comparison order. Will default to 10."""
|
|
32
|
+
"""Set the number of resoonses required per matchup/pairing for the comparison order. Will default to 10 if not set."""
|
|
33
|
+
if responses_required < 1:
|
|
34
|
+
raise ValueError("Responses required must be at least 1.")
|
|
35
|
+
|
|
33
36
|
self._responses_required = responses_required
|
|
34
37
|
return self
|
|
35
38
|
|
|
@@ -61,9 +64,10 @@ class CompareOrderBuilder:
|
|
|
61
64
|
self._validation_set_id = validation_set_id
|
|
62
65
|
return self
|
|
63
66
|
|
|
64
|
-
def
|
|
65
|
-
"""Set the
|
|
66
|
-
|
|
67
|
+
def confidence_threshold(self, confidence_threshold: float) -> 'CompareOrderBuilder':
|
|
68
|
+
"""Set the confidence threshold for early stopping.
|
|
69
|
+
That means that the order will either stop at the number of responses or when the confidence threshold is reached, whatever comes first."""
|
|
70
|
+
self._confidence_threshold = confidence_threshold
|
|
67
71
|
return self
|
|
68
72
|
|
|
69
73
|
def countries(self, country_codes: list[str]) -> 'CompareOrderBuilder':
|
|
@@ -103,14 +107,27 @@ class CompareOrderBuilder:
|
|
|
103
107
|
|
|
104
108
|
return self
|
|
105
109
|
|
|
106
|
-
@deprecated("Use .
|
|
110
|
+
@deprecated("Use .submit instead.")
|
|
107
111
|
def create(self, submit: bool = True, max_upload_workers: int = 10) -> 'RapidataOrder':
|
|
108
112
|
"""Create the classification order."""
|
|
109
|
-
return self.
|
|
113
|
+
return self.submit(submit=submit, disable_link=False)
|
|
110
114
|
|
|
111
115
|
def run(self, submit: bool = True, disable_link: bool = False) -> RapidataOrder:
|
|
112
116
|
"""Run the compare order.
|
|
113
117
|
|
|
118
|
+
Args:
|
|
119
|
+
submit (bool): Whether to submit the order. Defaults to True. \
|
|
120
|
+
Set this to False if you first want to see the order on your dashboard before running it.
|
|
121
|
+
disable_link (bool): Whether to disable the printing of the link to the order. Defaults to False.
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
RapidataOrder: The created compare order."""
|
|
125
|
+
|
|
126
|
+
return self.submit(submit=submit, disable_link=disable_link)
|
|
127
|
+
|
|
128
|
+
def submit(self, submit: bool = True, disable_link: bool = False) -> RapidataOrder:
|
|
129
|
+
"""Submit the compare order to be labeled.
|
|
130
|
+
|
|
114
131
|
Args:
|
|
115
132
|
submit (bool): Whether to submit the order. Defaults to True. \
|
|
116
133
|
Set this to False if you first want to see the order on your dashboard before running it.
|
|
@@ -119,10 +136,10 @@ class CompareOrderBuilder:
|
|
|
119
136
|
Returns:
|
|
120
137
|
RapidataOrder: The created compare order."""
|
|
121
138
|
|
|
122
|
-
if self.
|
|
139
|
+
if self._confidence_threshold:
|
|
123
140
|
referee = EarlyStoppingReferee(
|
|
124
141
|
max_vote_count=self._responses_required,
|
|
125
|
-
threshold=self.
|
|
142
|
+
threshold=self._confidence_threshold
|
|
126
143
|
)
|
|
127
144
|
|
|
128
145
|
else:
|
|
@@ -72,10 +72,22 @@ class FreeTextOrderBuilder:
|
|
|
72
72
|
self._settings.translation_behaviour(TranslationBehaviour.ONLY_TRANSLATED)
|
|
73
73
|
|
|
74
74
|
return self
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
def run(self, submit: bool = True, disable_link: bool = False) -> 'RapidataOrder':
|
|
77
77
|
"""Run the free text order.
|
|
78
78
|
|
|
79
|
+
Args:
|
|
80
|
+
submit (bool): Whether to submit the order. Defaults to True. \
|
|
81
|
+
Set this to False if you first want to see the order on your dashboard before running it.
|
|
82
|
+
disable_link (bool): Whether to disable the printing of the link to the order. Defaults to False.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
RapidataOrder: The created free text order."""
|
|
86
|
+
return self.submit(submit=submit, disable_link=disable_link)
|
|
87
|
+
|
|
88
|
+
def submit(self, submit: bool = True, disable_link: bool = False) -> 'RapidataOrder':
|
|
89
|
+
"""Submit the free text order to be labeled.
|
|
90
|
+
|
|
79
91
|
Args:
|
|
80
92
|
submit (bool): Whether to submit the order. Defaults to True. \
|
|
81
93
|
Set this to False if you first want to see the order on your dashboard before running it.
|
|
@@ -3,60 +3,60 @@ from rapidata.rapidata_client.order.rapidata_order import RapidataOrder
|
|
|
3
3
|
from rapidata.rapidata_client.order.rapidata_order_builder import RapidataOrderBuilder
|
|
4
4
|
from rapidata.rapidata_client.referee.naive_referee import NaiveReferee
|
|
5
5
|
from rapidata.rapidata_client.selection.base_selection import Selection
|
|
6
|
-
from rapidata.rapidata_client.workflow import
|
|
6
|
+
from rapidata.rapidata_client.workflow import SelectWordsWorkflow
|
|
7
7
|
from rapidata.rapidata_client.selection.validation_selection import ValidationSelection
|
|
8
8
|
from rapidata.rapidata_client.selection.labeling_selection import LabelingSelection
|
|
9
9
|
from rapidata.service.openapi_service import OpenAPIService
|
|
10
10
|
from rapidata.rapidata_client.assets import MediaAsset, BaseAsset
|
|
11
11
|
from rapidata.rapidata_client.filter import Filter, CountryFilter, LanguageFilter
|
|
12
|
-
from rapidata.rapidata_client.metadata import
|
|
12
|
+
from rapidata.rapidata_client.metadata import SelectWordsMetadata
|
|
13
13
|
from rapidata.rapidata_client.settings import Settings, TranslationBehaviour
|
|
14
14
|
|
|
15
|
-
class
|
|
15
|
+
class SelectWordsOrderBuilder:
|
|
16
16
|
def __init__(self,
|
|
17
17
|
name: str,
|
|
18
18
|
instruction: str,
|
|
19
19
|
media_assets: list[BaseAsset],
|
|
20
|
-
|
|
20
|
+
texts: list[SelectWordsMetadata],
|
|
21
21
|
openapi_service: OpenAPIService,
|
|
22
22
|
time_effort: int):
|
|
23
23
|
self._order_builder = RapidataOrderBuilder(name=name, openapi_service=openapi_service)
|
|
24
24
|
self._instruction = instruction
|
|
25
25
|
self._media_assets = media_assets
|
|
26
|
-
self.
|
|
26
|
+
self._texts = texts
|
|
27
27
|
self._validation_set_id = None
|
|
28
28
|
self._referee = NaiveReferee()
|
|
29
29
|
self._settings = Settings()
|
|
30
30
|
self._filters: list[Filter] = []
|
|
31
31
|
self._time_effort = time_effort
|
|
32
32
|
|
|
33
|
-
def responses(self, responses_required: int) -> '
|
|
34
|
-
"""Set the number of responses required per datapoint for the
|
|
33
|
+
def responses(self, responses_required: int) -> 'SelectWordsOrderBuilder':
|
|
34
|
+
"""Set the number of responses required per datapoint for the order. Will default to 10."""
|
|
35
35
|
self._referee = NaiveReferee(responses=responses_required)
|
|
36
36
|
return self
|
|
37
37
|
|
|
38
|
-
def validation_set(self, validation_set_id: str) -> '
|
|
39
|
-
"""Set the validation set for the
|
|
38
|
+
def validation_set(self, validation_set_id: str) -> 'SelectWordsOrderBuilder':
|
|
39
|
+
"""Set the validation set for the order."""
|
|
40
40
|
self._validation_set_id = validation_set_id
|
|
41
41
|
return self
|
|
42
42
|
|
|
43
|
-
def countries(self, country_codes: list[str]) -> '
|
|
43
|
+
def countries(self, country_codes: list[str]) -> 'SelectWordsOrderBuilder':
|
|
44
44
|
"""Set the countries where order will be shown as country codes."""
|
|
45
45
|
self._filters.append(CountryFilter(country_codes))
|
|
46
46
|
return self
|
|
47
47
|
|
|
48
|
-
def languages(self, language_codes: list[str]) -> '
|
|
48
|
+
def languages(self, language_codes: list[str]) -> 'SelectWordsOrderBuilder':
|
|
49
49
|
"""Set the languages where order will be shown as language codes."""
|
|
50
50
|
self._filters.append(LanguageFilter(language_codes))
|
|
51
51
|
return self
|
|
52
52
|
|
|
53
|
-
def wait_for_video_to_finish(self, offset: int = 0) -> '
|
|
53
|
+
def wait_for_video_to_finish(self, offset: int = 0) -> 'SelectWordsOrderBuilder':
|
|
54
54
|
"""Allows labeler to only answer once the video has finished playing.
|
|
55
55
|
The offset gets added on top. Can be negative to allow answers before the video ends."""
|
|
56
56
|
self._settings.play_video_until_the_end(offset)
|
|
57
57
|
return self
|
|
58
58
|
|
|
59
|
-
def translation(self, disable: bool = False, show_both: bool = False) -> '
|
|
59
|
+
def translation(self, disable: bool = False, show_both: bool = False) -> 'SelectWordsOrderBuilder':
|
|
60
60
|
"""Disable the translation of the order.
|
|
61
61
|
Only the instruction will be translated.
|
|
62
62
|
|
|
@@ -82,17 +82,24 @@ class TranscriptionOrderBuilder:
|
|
|
82
82
|
self._settings.translation_behaviour(TranslationBehaviour.ONLY_TRANSLATED)
|
|
83
83
|
|
|
84
84
|
return self
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
def run(self, submit: bool = True, disable_link: bool = False) -> 'RapidataOrder':
|
|
87
|
-
"""Run the
|
|
87
|
+
"""Run the order.
|
|
88
88
|
|
|
89
89
|
Args:
|
|
90
90
|
submit (bool): Whether to submit the order. Defaults to True. \
|
|
91
91
|
Set this to False if you first want to see the order on your dashboard before running it.
|
|
92
|
-
disable_link (bool): Whether to disable the printing of the link to the order. Defaults to False.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
disable_link (bool): Whether to disable the printing of the link to the order. Defaults to False."""
|
|
93
|
+
|
|
94
|
+
return self.submit(submit=submit, disable_link=disable_link)
|
|
95
|
+
|
|
96
|
+
def submit(self, submit: bool = True, disable_link: bool = False) -> 'RapidataOrder':
|
|
97
|
+
"""Submit the order to be labeled.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
submit (bool): Whether to submit the order. Defaults to True. \
|
|
101
|
+
Set this to False if you first want to see the order on your dashboard before running it.
|
|
102
|
+
disable_link (bool): Whether to disable the printing of the link to the order. Defaults to False."""
|
|
96
103
|
|
|
97
104
|
if (self._validation_set_id and MAX_TIME_IN_SECONDS_FOR_ONE_SESSION//self._time_effort - 1 < 1) or (MAX_TIME_IN_SECONDS_FOR_ONE_SESSION//self._time_effort < 1):
|
|
98
105
|
raise ValueError(f"The Labelers only have {MAX_TIME_IN_SECONDS_FOR_ONE_SESSION} seconds to do the task. \
|
|
@@ -106,12 +113,12 @@ class TranscriptionOrderBuilder:
|
|
|
106
113
|
|
|
107
114
|
order = (self._order_builder
|
|
108
115
|
.workflow(
|
|
109
|
-
|
|
116
|
+
SelectWordsWorkflow(
|
|
110
117
|
instruction=self._instruction
|
|
111
118
|
)
|
|
112
119
|
)
|
|
113
120
|
.referee(self._referee)
|
|
114
|
-
.media(self._media_assets, metadata=self.
|
|
121
|
+
.media(self._media_assets, metadata=self._texts)
|
|
115
122
|
.selections(selection)
|
|
116
123
|
.settings(self._settings)
|
|
117
124
|
.filters(self._filters)
|
|
@@ -120,36 +127,31 @@ class TranscriptionOrderBuilder:
|
|
|
120
127
|
return order
|
|
121
128
|
|
|
122
129
|
|
|
123
|
-
class
|
|
130
|
+
class SelectWordsMediaBuilder:
|
|
124
131
|
def __init__(self, name: str, instruction: str, openapi_service: OpenAPIService):
|
|
125
132
|
self._openapi_service = openapi_service
|
|
126
133
|
self._name = name
|
|
127
134
|
self._instruction = instruction
|
|
128
135
|
self._media_assets: list[BaseAsset] = []
|
|
129
|
-
self.
|
|
130
|
-
self._time_effort =
|
|
136
|
+
self._texts: list[SelectWordsMetadata] = []
|
|
137
|
+
self._time_effort = 10
|
|
131
138
|
|
|
132
|
-
def media(self, media_paths: list[str],
|
|
133
|
-
"""Set the media assets for the
|
|
139
|
+
def media(self, media_paths: list[str], texts: list[str], time_effort: int = 10) -> SelectWordsOrderBuilder:
|
|
140
|
+
"""Set the media assets for the order by providing the local paths to the audio / video files.
|
|
134
141
|
|
|
135
142
|
Args:
|
|
136
143
|
media_paths (list[str]): A local file path.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
Returns:
|
|
140
|
-
TranscriptionOrderBuilder: The transcription order builder instance.
|
|
141
|
-
|
|
142
|
-
Raises:
|
|
143
|
-
ValueError: If the media paths are not a list of strings."""
|
|
144
|
+
texts (list[str]): The text will be split up by spaces and the labeler will be able to select the words.
|
|
145
|
+
time_effort (int): Estimated time in seconds to solve one task for the first time. Defaults to 10."""
|
|
144
146
|
|
|
145
147
|
if not isinstance(media_paths, list) or not all(isinstance(path, str) for path in media_paths):
|
|
146
148
|
raise ValueError("Media paths must be a list of strings, the strings being file paths.")
|
|
147
149
|
|
|
148
|
-
if not isinstance(
|
|
149
|
-
raise ValueError("
|
|
150
|
+
if not isinstance(texts, list) or not all(isinstance(text, str) for text in texts):
|
|
151
|
+
raise ValueError("texts must be a list of strings.")
|
|
150
152
|
|
|
151
|
-
if not len(media_paths) == len(
|
|
152
|
-
raise ValueError("The number of media paths and
|
|
153
|
+
if not len(media_paths) == len(texts):
|
|
154
|
+
raise ValueError("The number of media paths and texts must be the same.")
|
|
153
155
|
|
|
154
156
|
invalid_paths: list[str] = []
|
|
155
157
|
for path in media_paths:
|
|
@@ -161,34 +163,34 @@ class TranscriptionMediaBuilder:
|
|
|
161
163
|
if invalid_paths:
|
|
162
164
|
raise FileNotFoundError(f"Could not find the following files: {invalid_paths}")
|
|
163
165
|
|
|
164
|
-
self.
|
|
166
|
+
self._texts = [SelectWordsMetadata(text) for text in texts]
|
|
165
167
|
|
|
166
168
|
self._time_effort = time_effort
|
|
167
169
|
return self._build()
|
|
168
170
|
|
|
169
|
-
def _build(self) ->
|
|
171
|
+
def _build(self) -> SelectWordsOrderBuilder:
|
|
170
172
|
if not self._media_assets:
|
|
171
173
|
raise ValueError("Please provide either a text or an media to be shown with the question")
|
|
172
|
-
return
|
|
174
|
+
return SelectWordsOrderBuilder(self._name,
|
|
173
175
|
self._instruction,
|
|
174
176
|
self._media_assets,
|
|
175
|
-
self.
|
|
177
|
+
self._texts,
|
|
176
178
|
openapi_service=self._openapi_service,
|
|
177
179
|
time_effort=self._time_effort)
|
|
178
180
|
|
|
179
181
|
|
|
180
|
-
class
|
|
182
|
+
class SelectWordsInstructionBuilder:
|
|
181
183
|
def __init__(self, name: str, openapi_service: OpenAPIService):
|
|
182
184
|
self._openapi_service = openapi_service
|
|
183
185
|
self._name = name
|
|
184
186
|
self._instruction = None
|
|
185
187
|
|
|
186
|
-
def instruction(self, instruction: str) ->
|
|
187
|
-
"""Set the instruction for the
|
|
188
|
+
def instruction(self, instruction: str) -> SelectWordsMediaBuilder:
|
|
189
|
+
"""Set the instruction for the order."""
|
|
188
190
|
self._instruction = instruction
|
|
189
191
|
return self._build()
|
|
190
192
|
|
|
191
|
-
def _build(self) ->
|
|
193
|
+
def _build(self) -> SelectWordsMediaBuilder:
|
|
192
194
|
if self._instruction is None:
|
|
193
195
|
raise ValueError("Instruction is required")
|
|
194
|
-
return
|
|
196
|
+
return SelectWordsMediaBuilder(self._name, self._instruction, self._openapi_service)
|
|
@@ -2,5 +2,5 @@ from .base_workflow import Workflow
|
|
|
2
2
|
from .classify_workflow import ClassifyWorkflow
|
|
3
3
|
from .compare_workflow import CompareWorkflow
|
|
4
4
|
from .free_text_workflow import FreeTextWorkflow
|
|
5
|
-
from .
|
|
5
|
+
from .select_words_workflow import SelectWordsWorkflow
|
|
6
6
|
from .evaluation_workflow import EvaluationWorkflow
|
|
@@ -4,26 +4,26 @@ from rapidata.api_client.models.transcription_rapid_blueprint import Transcripti
|
|
|
4
4
|
from rapidata.rapidata_client.workflow.base_workflow import Workflow
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class SelectWordsWorkflow(Workflow):
|
|
8
8
|
"""
|
|
9
|
-
A workflow for
|
|
9
|
+
A workflow for select words tasks.
|
|
10
10
|
|
|
11
|
-
This class represents a
|
|
11
|
+
This class represents a select words workflow where audio or video content
|
|
12
12
|
is transcribed based on given instructions.
|
|
13
13
|
|
|
14
14
|
Attributes:
|
|
15
|
-
_instruction (str): The instruction for the
|
|
15
|
+
_instruction (str): The instruction for the select words task.
|
|
16
16
|
|
|
17
17
|
Args:
|
|
18
|
-
instruction (str): The instruction to be provided for the
|
|
18
|
+
instruction (str): The instruction to be provided for the select words task.
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
21
|
def __init__(self, instruction: str):
|
|
22
22
|
"""
|
|
23
|
-
Initialize a
|
|
23
|
+
Initialize a SelectWordsWorkflow instance.
|
|
24
24
|
|
|
25
25
|
Args:
|
|
26
|
-
instruction (str): The instruction to be provided for the
|
|
26
|
+
instruction (str): The instruction to be provided for the select words task.
|
|
27
27
|
"""
|
|
28
28
|
super().__init__(type="SimpleWorkflowConfig")
|
|
29
29
|
self._instruction = instruction
|