repair_word_labels#
- pymovements.measure.reading.repair_word_labels(df: DataFrame) DataFrame[source]#
Ensure consistent word string labels within each word index group.
Normalizes the
wordcolumn so that all characters belonging to the same(trial, page, line_idx, word_idx)group share an identical word label.Whitespace-only or empty
wordentries are treated as missing and are forward- and backward-filled within each word group. Theword_idxcolumn is not modified.This is primarily used to assign a proper word label to characters such as inter-word spaces that already have a valid
word_idx, ensuring downstream processing operates on consistent word-level labels.- Parameters:
df (pl.DataFrame) – Character-level AOI table containing at least the columns
word_idx,word, andchar_idx_in_line. Optionally grouped bytrial,page, andline_idx.- Returns:
A copy of the input DataFrame with normalized
wordlabels. No rows are added or removed, andword_idxassignments remain unchanged.- Return type:
pl.DataFrame