krank.fetch_liwc#
- krank.fetch_liwc(dataset, version=None, load=True, target_dic=None, **kwargs)#
Fetch a LIWC scores dataset as a
pandas.DataFrame
.Calling this function will always retrieve/download the file from its remote source if it has not already been retrieved (via
pooch.retrieve()
).Refer to the online
krank.liwc
documentation for more details about the module and available LIWC scores datasets.Note
Custom loading
To apply custom loading, either (1) set
load=False
to return the local filepath and load the file in subsequent steps, or (2) pass a callable function toload
and it will be used to load the file instead of thekrank
default loader.See also
This is a top-level wrapper around dataset-specific functions in the
krank.lexicons
module. For example, callingkrank.fetch_liwc("barrett2020")
is identical to callingkrank.tables.fetch_barrett2020()
.Parameters#
- datasetstr
Name of dataset (i.e., lexicon). Refer to the
lexicons
documentation for a list of all available datasets.- versionstr or None
Name of version. If
None
(default), fetches the latest version. Refer to thelexicons
documentation for a list of all available versions within each dataset.- loadbool or callable
If
False
(default), fetch the file and return the local filepath. IfTrue
, fetch the file and load it as apandas.DataFrame
. If a callable, fetch the file an load it with the custom callable.- target_dicstr or None
If
None
(default), LIWC categories remain in their original format. If notNone
, LIWC categories are converted from the source dictionary (whatever was used in the original study) to the specifiedtarget_dic
. Iftarget_dic
is the same as the source dictionary, no action is taken. If notNone
, must be one ofLIWC1999
,LIWC2001
,LIWC2007
,LIWC2015
, orLIWC-22
.Warning
This feature is experimental.
Categories change between versions of LIWC, and so these are far from comparable. Some categories will not be present in both source and target dictionaries, and thus removed from the returned dataframe. Other categories might have close-but-imperfect fits or might have changed drastically between LIWC versions. In this case, the conversions are still provided, so be careful with interpretations. A useful resource if wanting to use scores pooled across LIWC versions would be the LIWC manuals, where comparisons between LIWC versions are described in detail and analyses comparing output across LIWC versions are presented.
- **kwargsdict, optional
Additional keyword arguments are passed to
pooch.retrieve()
.
Returns#
- str or
DataFrame
Path of retrieved file if
load
is False, orpandas.DataFrame
ifload
is True.