pliers.extractors.PredefinedDictionaryExtractor

class pliers.extractors.PredefinedDictionaryExtractor(variables, missing=nan, case_sensitive=False, force_retrieve=False)[source]

Bases: DictionaryExtractor

A generic Extractor that maps words onto values via one or more pre-defined dictionaries accessed via the web.

Parameters
  • variables (list or dict) – A specification of the dictionaries and column names to map the input TextStims onto. If a list, each element must be a string with the format ‘dict/column’, where the value before the slash gives the name of the dictionary, and the value after the slash gives the name of the column in that dictionary. These names can be found in the dictionaries.json specification file under the datasets submodule. Examples of valid values are ‘affect/V.Mean.Sum’ and ‘subtlexusfrequency/Lg10WF’. If a dict, the keys are the names of the dictionary files (e.g., ‘affect’), and the values are lists of columns to use (e.g., [‘V.Mean.Sum’, ‘V.SD.Sum’]).

  • missing (object) – Value to use when an entry for a word is missing in a dictionary (defaults to numpy’s NaN).

  • case_sensitive (bool) – If True, entries in the dictionary are treated as case-sensitive (e.g., ‘John’ and ‘john’ are different words).

  • force_retrieve (bool) – If True, the source dictionary will always be retrieved/download, even if it exists locally. If False, a cached local version will be used if it exists.

__init__(variables, missing=nan, case_sensitive=False, force_retrieve=False)[source]
transform(stim, *args, **kwargs)

Executes the transformation on the passed stim(s).

Parameters
  • stims (str, Stim, list) –

    One or more stimuli to process. Must be one of:

    • A string giving the path to a file that can be read in as a Stim (e.g., a .txt file, .jpg image, etc.)

    • A Stim instance of any type.

    • An iterable of stims, where each element is either a string or a Stim.

  • validation (str) –

    String specifying how validation errors should be handled. Must be one of:

    • ’strict’: Raise an exception on any validation error

    • ’warn’: Issue a warning for all validation errors

    • ’loose’: Silently ignore all validation errors

  • args – Optional positional arguments to pass onto the internal _transform call.

  • kwargs – Optional positional arguments to pass onto the internal _transform call.