Skip to content

euroeval.string_utils

source module euroeval.string_utils

Utility functions related to string manipulation or structuring.

Functions

source scramble(text: str)str

Scramble a string in a bijective manner.

Parameters

  • text : str The string to scramble.

Returns

  • str The scrambled string.

source unscramble(scrambled_text: str)str

Unscramble a string in a bijective manner.

Parameters

  • scrambled_text : str The scrambled string to unscramble.

Returns

  • str The unscrambled string.

source extract_json_dict_from_string(s: str)dict | None

Extract a JSON dictionary from a string.

Parameters

  • s : str The string to extract the JSON dictionary from.

Returns

  • dict | None The extracted JSON dictionary, or None if no JSON dictionary could be found.

source extract_multiple_choice_labels(prompt: str, candidate_labels: c.Sequence[str])c.Sequence[str]

Extract multiple choice labels from a prompt.

Parameters

  • prompt : str The prompt to extract the labels from.

  • candidate_labels : c.Sequence[str] The candidate labels to look for in the prompt.

Returns

  • c.Sequence[str] The extracted labels.

Raises

source split_model_id(model_id: str)ModelIdComponents

Split a model ID into its components.

Parameters

  • model_id : str The model ID to split.

Returns

Raises