liwca.liwc22#

liwca.liwc22(mode, *, auto_open=False, use_gui=False, dry_run=False, **kwargs)[source]#

Execute a LIWC-22 CLI analysis from Python.

The LIWC-22 desktop application (or its license server) must be running before calling this function. Pass auto_open=True to let liwca start and stop it automatically.

Parameters:
  • mode (str) – Analysis mode — one of "wc", "freq", "mem", "context", "arc", "ct", "lsm".

  • auto_open (bool, optional) – If LIWC-22 is not running, launch it before analysis and close it afterwards (default False).

  • use_gui (bool, optional) – When auto-opening, prefer the GUI app over the headless license server (default False).

  • dry_run (bool, optional) – Print the CLI command without executing it (default False).

  • **kwargs (Any) – Mode-specific arguments. Use the Python dest names from the argument catalogue (underscored, e.g. input="data.txt", output="results.csv", output_format="xlsx").

Returns:

Return code from the LIWC-22 CLI process (0 = success).

Return type:

int

Raises:
  • ValueError – If mode is not a recognised analysis mode.

  • SystemExit – If LIWC-22 is not running and auto_open is False.

See also

count : Pure-Python word counting (no LIWC-22 required). LIWC CLI documentation Python CLI example

Examples

>>> liwc22("wc", input="data.txt", output="results.csv")
0
>>> liwc22("wc", input="data.txt", output="results.csv", dry_run=True)
0