ducho.internal.utils package

Submodules

ducho.internal.utils.TextualFileManager module

class ducho.internal.utils.TextualFileManager.TextualFileManager(columns)[source]

Bases: object

build_path_from_id(id_)[source]

Build the name of the output file for a single processed sentence.

This method constructs the name of the output file for a single processed sentence. Later, this name will be used to build the complete path of the single output file.

Parameters:

id (Any) – The row ID. This is used only to build the name.

Returns:

The output file name. This is not the complete path or the complete name of the file (it misses the extension).

Return type:

str

get_item_from_id(idx)[source]

Retrieve the sentence to be elaborated for a specific row of the file.

If the origin of elaboration is from interactions, it searches the sentence in the ‘comment’ column. Otherwise, if the origin is from item description, it searches the sentence in the ‘description’ column.

Parameters:

idx (Any) – The row from which to retrieve the sentence.

Returns:

The sentence to be elaborated. Preprocessing may be needed.

Return type:

str

initiate_element_list_and_get_len()[source]

Read the file, instantiate the internal list of its contents, and return the number of sentences to be elaborated.

Returns:

A tuple containing the length of the object to be elaborated and a list of IDs.

Return type:

Tuple[int, List[Any]]

set_file_path(file_path)[source]

Set the absolute path of the textual input file that will be opened later.

Parameters:

file_path (str) – The absolute path of the input file as a string.

Returns:

None

set_type_of_extraction(type_of_extraction)[source]

Set type of extraction which is the source of the input: from user interaction or from items. Here it is needed to across correctly the file and for build the name of the output file at the end of the extraction :param type_of_extraction: The type of extraction, either ‘interactions’ or ‘items’. :type type_of_extraction: str

Returns:

None

ducho.internal.utils.YamlFileManager module

class ducho.internal.utils.YamlFileManager.YamlFileManager(yaml_file_path)[source]

Bases: object

get_default_dict()[source]

it simply loads the data contained in the default config file :returns: the String that is contained in the default yaml file

get_raw_dict()[source]

it simply loads the data contained in the file :returns: the String that is contained in the yaml file

ducho.internal.utils.human_sorting module

ducho.internal.utils.human_sorting.human_sort(unsorted_list)[source]

Sorts a list of strings both alphabetically and numerically.

This function sorts the list in such a way that it follows both the alphabetical order and the numerical order. For example, [‘10’,’2’,’1’,’8’] will be sorted as [‘1’,’2’,’8’,’10’].

Parameters:

unsorted_list (List[str]) – The list of strings to sort.

Returns:

The sorted list of strings.

Return type:

List[str]

ducho.internal.utils.model_map module

Module contents