unitxt.text_utils module
- unitxt.text_utils.camel_to_snake_case(s)
Converts a string from camelCase to snake_case.
- Parameters:
s (str) – The string to be converted.
- Returns:
The string converted to snake_case.
- Return type:
str
- unitxt.text_utils.construct_dict_str(d, indent=0, indent_delta=4, max_chars=None)
Constructs a formatted string of a dictionary.
- Parameters:
d (dict) – The dictionary to be formatted.
indent (int, optional) – The current level of indentation. Defaults to 0.
indent_delta (int, optional) – The amount of spaces to add for each level of indentation. Defaults to 4.
max_chars (int, optional) – The maximum number of characters for each line. Defaults to terminal width - 10.
- unitxt.text_utils.is_camel_case(s)
Checks if a string is in camelCase.
- Parameters:
s (str) – The string to be checked.
- Returns:
True if the string is in camelCase, False otherwise.
- Return type:
bool
- unitxt.text_utils.is_snake_case(s)
Checks if a string is in snake_case.
- Parameters:
s (str) – The string to be checked.
- Returns:
True if the string is in snake_case, False otherwise.
- Return type:
bool
- unitxt.text_utils.nested_tuple_to_string(nested_tuple: tuple) str
Converts a nested tuple to a string, with elements separated by underscores.
- Parameters:
nested_tuple (tuple) – The nested tuple to be converted.
- Returns:
The string representation of the nested tuple.
- Return type:
str
- unitxt.text_utils.print_dict(d, indent=0, indent_delta=4, max_chars=None)
- unitxt.text_utils.split_words(s)
Splits a string into words based on PascalCase, camelCase, snake_case, kebab-case, and numbers attached to strings.
- Parameters:
s (str) – The string to be split.
- Returns:
The list of words obtained after splitting the string.
- Return type:
list