config Package

skll.config.fix_json(json_string)[source]

Fix incorrectly formatted quotes and capitalized booleans in JSON string.

Parameters:

json_string (str) – A JSON-style string.

Returns:

The normalized JSON string.

Return type:

str

skll.config.load_cv_folds(folds_file, ids_to_floats=False)[source]

Load cross-validation folds from a CSV file.

The CSV file must contain two columns: example ID and fold ID (and a header).

Parameters:
  • folds_file (skll.types.PathOrStr) – The path to a folds file to read.

  • ids_to_floats (bool, default=False) – Whether to convert IDs to floats.

Returns:

Dictionary with example IDs as the keys and fold IDs as the values. If ids_to_floats is set to True, the example IDs are floats but otherwise they are strings.

Return type:

skll.types.FoldMapping

Raises:

ValueError – If example IDs cannot be converted to floats and ids_to_floats is True.

skll.config.locate_file(file_path, config_dir)[source]

Locate a file, given a file path and configuration directory.

Parameters:
Returns:

path_to_check – The normalized absolute path, if it exists.

Return type:

str

Raises:

FileNotFoundError – If the file does not exist.