onestop
ArgsParser
Bases: Tap
Args parser for preprocessing.py
Note, for fixation data, the X_IA_DWELL_TIME, for X in
[total, min, max, part_total, part_min, part_max]
columns are computed based on the CURRENT_FIX_DURATION column.
Note, documentation was generated automatically. Please check the source code for more info.
Args: SURPRISAL_MODELS (list[str]): Models to extract surprisal from unique_item_columns (list[str]): columns that make up a unique item (Path | None): Path to question difficulty data from prolific mode (Mode): whether to use interest area or fixation data
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
Mode
Bases: Enum
Enum for processing mode. Defines whether to process interest area (IA) or fixation data.
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
230 231 232 233 234 235 236 237 | |
OneStopProcessor
Bases: DatasetProcessor
Processor for OneStop dataset
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
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 61 62 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 126 127 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 | |
add_ia_report_features_to_fixation_data(ia_df, fix_df)
Merge per‑IA (interest‑area) features into the fixation‑level data.
Result: one row per fixation, enriched with IA‑level attributes.
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
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 | |
dataset_specific_processing(data_dict)
OneStop-specific processing steps
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
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 126 127 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 | |
get_column_map(data_type)
Get column mapping for OneStop dataset
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
38 39 40 41 42 | |
get_columns_to_keep()
Get list of columns to keep after filtering
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
query_onestop_data(data, query)
Process the raw data by applying a query
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
156 157 158 159 160 161 162 163 | |
add_additional_metrics(df)
Add additional metrics to the DataFrame.
Adds columns for regression rate, total skip, and part length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: DataFrame with added metrics |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
add_unique_paragraph_id(df)
Add unique paragraph ID to the DataFrame.
Creates a new column 'unique_paragraph_id' by combining article_batch, article_id, difficulty_level, and paragraph_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: DataFrame with added unique paragraph ID |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
adjust_indexing(df, args)
Adjust indexing to be 0-indexed.
Subtracts 1 from specified columns based on whether in IA or FIXATION mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame |
required |
args
|
ArgsParser
|
Contains mode configuration |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: DataFrame with adjusted indexing |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | |
compute_normalized_features(df, duration_col, ia_field)
Calculate normalized versions of key metrics.
Adds columns for: - Normalized dwell times (total and by part) - Normalized word positions (total and by part) - Reverse indices from end
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame |
required |
duration_col
|
str
|
Column name for duration values |
required |
ia_field
|
str
|
Column name for word/fixation index |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: DataFrame with normalized metrics |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | |
compute_span_level_metrics(df, ia_field, mode, duration_col)
Calculate aggregated metrics for different text spans.
Computes: - Total dwell time per trial/span - Min/max word indices per trial/span - For fixations: count per span - Normalizes indices to start at 0
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame |
required |
ia_field
|
str
|
Column name for word/fixation index |
required |
mode
|
Mode
|
IA or FIXATION processing mode |
required |
duration_col
|
str
|
Column name for duration values |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: DataFrame with added span-level metrics |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | |
compute_start_end_line(df)
Compute for each word whether it the first/last word in the line (not sentence!).
This function adds two new columns to the input DataFrame: 'start_of_line' and 'end_of_line'. A word is considered to be at the start of a line if its 'IA_LEFT' value is smaller than the previous word's. A word is considered to be at the end of a line if its 'IA_LEFT' value is larger than the next word's.
df (pd.DataFrame): Input DataFrame. Must contain the columns 'participant_id', 'unique_paragraph_id', and 'IA_LEFT'.
Returns: pd.DataFrame: The input DataFrame with two new columns: 'start_of_line' and 'end_of_line'.
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
convert_to_float_features(df, args)
Convert specified columns to float type.
Handles missing values and dots by replacing them with None before conversion. Different columns are processed based on whether in IA or FIXATION mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame |
required |
args
|
ArgsParser
|
Contains mode configuration |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: DataFrame with converted float columns |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
convert_to_int_features(df, args)
Convert specified columns to integer type.
Handles missing values and dots by replacing them with 0 before conversion. Different columns are processed based on whether in IA or FIXATION mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame |
required |
args
|
ArgsParser
|
Contains mode configuration |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: DataFrame with converted integer columns |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 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 | |
drop_missing_fixation_data(df, args)
Drop rows with missing fixation data.
Drops rows with missing values in specified columns for FIXATION mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame |
required |
args
|
ArgsParser
|
Contains mode configuration |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: DataFrame with dropped rows |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
get_article_data(article_id, raw_text)
Retrieve article data from raw text by article ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
article_id
|
str
|
Article identifier to look up |
required |
raw_text
|
dict
|
Raw text data containing articles |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Article data if found |
Raises:
| Type | Description |
|---|---|
ValueError
|
If article ID not found |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | |
get_constants_by_mode(mode)
Get constants based on processing mode.
Returns duration and IA field names based on whether in IA or FIXATION mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
Processing mode (IA or FIXATION) |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
tuple[str, str]: Duration and IA field names |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | |
get_raw_text(args)
Load raw text data from OneStopQA JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
object
|
Configuration containing onestopqa_path |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Raw text data from OneStopQA JSON |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | |
our_processing(df, args)
LaCC lab-specific processing pipeline for OneStop dataset.
Extends the public dataset with additional features including: - Integer and float feature conversions - Index adjustments - Fixation data cleaning - Unique paragraph ID addition - Word span metrics computation - Span-level metrics computation - Feature normalization - Question difficulty data integration - Previous word metrics (for IA mode) - Line position metrics (for IA mode)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame from public preprocessing |
required |
args
|
ArgsParser
|
Configuration parameters |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Extended DataFrame with LaCC lab features |
Source code in src/data/preprocessing/dataset_preprocessing/onestop.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |