Cli
Command-line helpers for normalizing values in JSON Lines files.
Functions:
| Name | Description |
|---|---|
process_json_lines_file |
Normalize values in a JSON Lines file with a normalizer. |
main |
Run the command-line interface. |
NormalizationMethod(add_arguments, create_normalizer, help, description)
dataclass
Configure a normalization method for the command-line interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
add_arguments
|
Callable[[ArgumentParser], None]
|
Function that adds method-specific command-line arguments. |
required |
create_normalizer
|
Callable[[Namespace], Normalizer]
|
Function that creates a normalizer from parsed command-line arguments. |
required |
process_json_lines_file(input_path, output_path, read_key, write_key, normalizer, parent_keys=None, encoding='utf-8', replace_input=False)
Normalize values in a JSON Lines file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_path
|
Path
|
Path to the input JSON Lines file. |
required |
output_path
|
Path
|
Path to the normalized JSON Lines file. |
required |
read_key
|
str
|
Key to extract the value or list of values from each JSON object. |
required |
write_key
|
str
|
Key to write the normalized value or list of normalized values to. |
required |
normalizer
|
Normalizer
|
Function used to normalize one value. |
required |
parent_keys
|
list[str] | None
|
Parent keys to navigate before reading a value. Each level may contain a nested dictionary or a list of nested dictionaries. |
None
|
encoding
|
str
|
Encoding to use for reading and writing JSON Lines files. |
'utf-8'
|
replace_input
|
bool
|
If True, the input file will be replaced with the normalized output. A backup of the original input file will be saved to output_path. |
False
|
Source code in src/kibad_llm/normalization/cli.py
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 273 274 275 276 277 278 279 280 281 282 | |
main()
Parse command-line arguments and normalize values in one or multiple JSON Lines files.
Source code in src/kibad_llm/normalization/cli.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |