Word pool (stimpool.words)

The WordPool class contains all the functionality for creating word pools. It contains methods for sampling from the pool, selecting words based on their characteristics, getting the cleaned word pool, and saving it to a file.

class stimpool.words.WordPool(pool=None, clean_conjugation_suffix=True)[source]

Create word pools.

Create a word pool.

Parameters
  • pool (Iterable) – Word pool that will be used to create subpool (the default is None, use default word pool)

  • clean_conjugation_suffix (bool) – Specifies if suffixes that are used to identify word conjugations should be removed from the pool (Default=True)

Methods:

select_words_without_accented_characters()

Get words without accented characters.

select_words_of_length([min_len, max_len])

Get words of the length specified.

sample_pool(n[, reproducible])

Sample from the word pool.

save_pool([filename])

Save the word pool to a csv file.

Attributes:

words

Return the clean word pool.

select_words_without_accented_characters()[source]

Get words without accented characters.

Accented characters:: á, é, í, ó, ú, ñ, ü

Return type

None

select_words_of_length(min_len=None, max_len=None)[source]

Get words of the length specified.

Parameters
  • min_len (int) – Minimum word length (defaults to None; no min length). If a min length is not specified, a max length has to be specified.

  • max_len (int) – Maximum word length (defaults to None; no max length). If a max length is not specified, a min length has to be specified.

Raises

ValueError – If neither min_len nor max_len are specified.

Return type

None

sample_pool(n, reproducible=True)[source]

Sample from the word pool.

This is just a helper function that uses pandas.Series.sample. You can read its [complete documentation] (https://pandas.pydata.org/docs/reference/api/pandas.Series.sample.html)

Parameters
  • n (int) – sample size

  • reproducible (bool) – Specifies whether the sample obtained should be reproducible. This is important to guarantee the reproducibility of research (Default=True)

Return type

None

save_pool(filename='word pool')[source]

Save the word pool to a csv file.

This is just a helper function that uses pandas.Series.to_csv. You can read its [complete documentation] (https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.Series.to_csv.html)

Parameters

filename (str) – Name of the file without the extension (i.e., csv). (Default=word pool)

Return type

None

property words

Return the clean word pool.

Return type

Series