Operations
Operations are functions that operate on either a list of the examples or a single example. If the function operates on a single example, Recon will take care of applying it to all examples in a dataset.
The following operations are built into Recon
Error
... full list of operations to come
Operation
¶
Operation class that takes care of calling and reporting the results of an operation on a Dataset
Source code in recon/operations.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
|
__call__(dataset, *args, verbose=False, initial_state=None, **kwargs)
¶
Runs op on a dataset and records the results
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
Dataset
|
Dataset to operate on |
required |
Raises:
Type | Description |
---|---|
ValueError
|
if track_example is called in the op with no data |
Returns:
Name | Type | Description |
---|---|---|
OperationResult |
OperationResult
|
Container holding new data and the state of the Operation |
Source code in recon/operations.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
|
__init__(name, pre, op, handles_tokens, augmentation)
¶
Initialize an Operation instance
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of operation |
required |
pre |
List[PreProcessor]
|
List of preprocessors to run |
required |
op |
Op
|
Operation callable |
required |
Source code in recon/operations.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
operation
¶
Decorator for a Recon Operation. An Operation is python function that Recon
uses will map over each example in a dataset, tracking changes made to examples
by hash so dataset changes can back.
An operation has 1 required positional argument called "example" with the
"recon.types.Example" type.
Any other arguments are allowed and can be provided by
passing them to Dataset.apply_
Example operation:
@operation("my_custom_operation")
def rename_labels(example: Example, *, my_kwarg1: str, my_kwarg2: str)
Source code in recon/operations.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
__call__(op)
¶
Decorator for an operation. The first arg to the op callable needs to be a example. Recon will take care of applying it to a full Dataset
Parameters:
Name | Type | Description | Default |
---|---|---|---|
op |
Op
|
First arg is the function to decorate |
required |
Returns:
Name | Type | Description |
---|---|---|
Op |
OperationProtocol
|
The original function |
Source code in recon/operations.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
__init__(name, *, pre=[], handles_tokens=True, factory=False, augmentation=False)
¶
Decorate an operation that makes some changes to a dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Operation name. |
required |
pre |
Union[List[str], List[PreProcessor]]
|
List of preprocessors to run |
[]
|
Source code in recon/operations.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
op_iter(data, pre, verbose=True)
¶
Iterate over list of examples for an operation yielding tuples of (example hash, example)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
List[Example]
|
List of examples to iterate |
required |
pre |
List[PreProcessor]
|
List of preprocessors to run |
required |
verbose |
bool
|
Show verbose output. |
True
|
Yields:
Type | Description |
---|---|
int
|
Iterator[Tuple[int, Example]]: Tuples of (example hash, example) |
Source code in recon/operations.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|