dispel.providers.bdh.tasks.typing.keyboard module#

Keyboard functions to extract relevant properties for Typing.

dispel.providers.bdh.tasks.typing.keyboard.apply_similarity_ratio(submission_state)[source]#

Apply similarity ratio.

The similarity ratio is computed between the word being typed displayed_input and the word on screen displayed_word.

Parameters:

submission_state (DataFrame) – A data frame that contains the user state after each keystroke.

Returns:

  • Similarity ratio between the displayed input and

  • displayed_word.

Return type:

Series

dispel.providers.bdh.tasks.typing.keyboard.compute_rt_slope(df_reaction_time, col)[source]#

Compute the mean of the reaction time slope.

Parameters:
  • df_reaction_time (pd.DataFrame) – The reaction time dataframe (first letter and first correct letter)

  • col (String) – The column to be used : reaction_time or reaction_time_first_correct

Returns:

A float which is the mean slope of the reaction time (first letter

or first correct letter)

Return type:

float

dispel.providers.bdh.tasks.typing.keyboard.compute_typing_speed_slope(word, submission_state)[source]#

Compute the slope of the typing speed.

Parameters:
Return type:

float

dispel.providers.bdh.tasks.typing.keyboard.count_incorrect_words(word)[source]#

Count the number of incorrect words.

Parameters:

word (pd.DataFrame) – A data frame of the words.

Returns:

The number of incorrect words.

Return type:

int

dispel.providers.bdh.tasks.typing.keyboard.count_key_pressed(key_pressed, alphabet=False)[source]#

Count the number of keys pressed.

Parameters:
  • key_pressed (Series) – A pd.Series indicating the key pressed during the test.

  • alphabet (bool) – An optional argument indicating if the count should be done on alphabet letters only.

Returns:

The number of keys pressed.

Return type:

int

dispel.providers.bdh.tasks.typing.keyboard.count_words_typed_in_row(data, error_free=True)[source]#

Count the successfully typed words with(out) error in a row.

The parameter error_free indicates if we look at consecutive words that has been successfully typed and: without error (True) or with error (False).

Parameters:
  • data (DataFrame) – Dataframe containing typing data

  • error_free (bool) – If True, only count words typed with no error

Return type:

Number of words typed in a row

dispel.providers.bdh.tasks.typing.keyboard.detect_key_autocompletion(submission_state)[source]#

Detect the autocompletion at the key level.

Create a data frame that contains all the typed keys the autocompletion status.

Parameters:

submission_state (pd.DataFrame) – A data frame that contains the user state after each keystroke.

Returns:

An new dataset with the displayed word, all the key typed and autocompletion information.

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.detect_word_autocompletion(keys_with_autocompletion)[source]#

Detect the autocompletion for all the words.

Parameters:

keys_with_autocompletion (pd.DataFrame) – A data frame that .

Returns:

The word dataset without the autocompleted words

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.filter_intervals(data, differentiate)[source]#

Compute letter intervals prior a mistake within a word.

Parameters:
Return type:

Series

dispel.providers.bdh.tasks.typing.keyboard.find_consec_element_and_count(data)[source]#

Find consecutive elements and count them.

Parameters:

data (pd.DataFrame) – Data frame to compute measure related to successfully written words with(out) error, and also a streak of words with(out) error(s).

Returns:

A data frame with three columns: the count, the submission state and if the sequence was free of error

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.get_correct_correcting_duration(correcting_duration)[source]#

Return correcting duration for correct words.

Parameters:

correcting_duration (pd.DataFrame) – Data frame containing correcting durations.

Returns:

A data frame that contains correcting duration for correct words.

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.get_correct_reacting_time(reacting_times)[source]#

Return reacting times for correct words.

Parameters:

reacting_times (pd.DataFrame) – Data frame containing correction differences.

Returns:

A data frame that contains reacting duration for correct words.

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.get_correct_reaction_duration(reaction_duration)[source]#

Return reaction durations for correct words.

Parameters:

reaction_duration (pd.DataFrame) – Data frame containing reacting durations.

Returns:

A data frame that contains reaction duration for correct words.

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.get_correcting_duration(state_durations)[source]#

Compute correcting duration.

The Correcting Duration is the time elapsed in a correcting state for a correct submission, in other words, the time spent correcting a mistake.

Parameters:

state_durations (pd.DataFrame) – Data frame containing submission states and duration.

Returns:

A data frame that contains correcting duration.

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.get_reacting_times(state_durations)[source]#

Return reacting times.

The reacting time is the time elapsed between an incorrect state and a correcting state for a correct submission, in other words, the time to react to a mistake.

Parameters:

state_durations (pd.DataFrame) – Data frame containing submission states and duration.

Returns:

A data frame containing reacting times.

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.get_reaction_duration(state_durations)[source]#

Compute the reaction duration.

The reaction duration is the time elapsed in an incorrect state for a correct submission.

Parameters:

state_durations (pd.DataFrame) – Data frame containing submission states and duration.

Returns:

A data frame that contains reaction duration.

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.get_state_durations(submission_state, key_intervals, word)[source]#

Return submission state duration.

To compute the state duration, we group by displayed word and by submission state. Indeed, we want to compute statistics per word on the time spent in a given state or between states.

Parameters:
  • submission_state (pd.DataFrame) – Data frame containing the submission state each time a user types a key.

  • key_intervals (pd.DataFrame) – Time intervals between samples

  • word (pd.DataFrame) – A data frame listing all the words displayed on screen during the test with the following columns: words, appearance_timestamp and disappearance_timestamp.

Returns:

A data frame that contains duration of each correcting state.

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.get_submission_state(word, key_typed)[source]#

Compute the submission state.

Create a data frame that contains the state at each time a user types a key. Available states are the following: Correct, Incorrect, and Correcting. The state is Correct if the textbox is empty or if it forms a subpart of the word displayed on the screen. The state is incorrect whenever the user types a key (that is not backspace), leading to a textbox that does not form a subpart of the word displayed on the screen. Finally, the state is identified as correcting whenever the user corrects its mistake by typing backspace; it can be seen as an intermediate state between an incorrect and a correct state.

Parameters:
  • word (pd.DataFrame) – A data frame listing all the words displayed on screen during the test with the following columns: words, appearance_timestamp and disappearance_timestamp.

  • key_typed (pd.DataFrame) – The dataframe with the list of key pressed by the user, it should contain the columns: timestamp_out and key.

Returns:

A data frame that contains the user state after each keystroke.

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.interval_until_mistake(submission_state, key_is_letter, differentiate)[source]#

Compute letter intervals prior a mistake for each word.

Parameters:
Return type:

DataFrame

dispel.providers.bdh.tasks.typing.keyboard.keep_top_ten(data)[source]#

Keep top 10% intervals.

Parameters:

data (DataFrame) – A dataframe of letter intervals with the column letter_intervals.

Return type:

The top 10 percent letter intervals.

dispel.providers.bdh.tasks.typing.keyboard.letter_interval(key_is_letter, key_intervals, extra_mask=None)[source]#

Compute the interval between two consecutive letters.

Parameters:
  • key_is_letter (Series) – A boolean series indicating if a key is a letter.

  • key_intervals (Series) – A series of float indicating the time between two consecutive keys.

  • extra_mask (Series | None) – An optional series of boolean that will be used as an extra mask to filter intervals.

Returns:

The first element of the tuple is the time between each consecutive letter keys. The second element is the mask that has been used to filter the key_intervals to find the letters of interests.

Return type:

Tuple[pd.Series, pd.Series]

dispel.providers.bdh.tasks.typing.keyboard.max_letter_interval_dev(data)[source]#

Compute the maximum letter interval deviation from the mean.

Parameters:

data (DataFrame) –

Return type:

Series

dispel.providers.bdh.tasks.typing.keyboard.ratio_key_pressed(submission_state, word)[source]#

Group by word and count the letters typed for completed words.

Parameters:
  • submission_state (DataFrame) – A data frame that contains the user state after each keystroke.

  • word (DataFrame) – A data frame listing all the words displayed on screen during the test with the following columns: words, appearance_timestamp and disappearance_timestamp.

Returns:

A data frame with a column letters_typed_over_length containing the following ratio: number of letters typed divided by the length of the word (for completed words).

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.similarity_ratio(x)[source]#

Compute the similarity ratio.

Parameters:

x (Series | DataFrame) –

Return type:

float

dispel.providers.bdh.tasks.typing.keyboard.time_intervals(data, interval_column)[source]#

Find time intervals between consecutive element of a data frame.

Parameters:
  • data (pd.DataFrame) – Any data frame with a timestamp index.

  • interval_column (Optional[str]) – When specified, indicates that the interval should be computed with values from a column and not the index.

Returns:

Time intervals between samples.

Return type:

pd.Series

dispel.providers.bdh.tasks.typing.keyboard.total_autocomplete(keys_with_autocompletion)[source]#

Get the total number of autocompletions.

Parameters:

keys_with_autocompletion (pd.DataFrame) – A dataframe indicating whether a key was autocompleted or not.

Returns:

Number of autocompletions performed by the user.

Return type:

int

dispel.providers.bdh.tasks.typing.keyboard.total_words_typed(word)[source]#

Find total number of words typed.

The total number of words typed successfully is the number of True values in the columns success.

Parameters:

word (pd.DataFrame) – A data frame containing the word information with the column success.

Returns:

Number of words successfully typed.

Return type:

int

dispel.providers.bdh.tasks.typing.keyboard.transform_reaction_time(word, key_typed)[source]#

Compute the reaction time and the first correct letter reaction time.

The reaction time is the time elapsed between the appearance of a word and the time the user typed a letter. The first correct letter reaction time follows the same definition but measures the time elapsed until a correct letter is typed.

Parameters:
  • word (pd.DataFrame) – A data frame listing all the words displayed on screen during the test with the following columns: words, appearance_timestamp and disappearance_timestamp.

  • key_typed (pd.DataFrame) – The dataframe with the list of key pressed by the user, it should contain the columns: timestamp_out and key.

Returns:

A DataFrame with two columns: the reaction time and the reaction time to the first correct letter.

Return type:

pd.DataFrame

dispel.providers.bdh.tasks.typing.keyboard.word_duration(word)[source]#

Compute the time spent per word.

Parameters:

word (pd.DataFrame) – A data frame containing the word information with the column success.

Returns:

A data frame containing the time spent per word.

Return type:

pd.Series