Mergers
Defines a collection of merger functions.
concatenate(delimiter='-')
Creates a function that concatenates a list of values with a delimiter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delimiter
|
str
|
The delimiter to use when concatenating the values. Defaults to "-". |
'-'
|
Returns:
| Type | Description |
|---|---|
Callable[[list[Any]], str]
|
Callable[[list[Any]], str]: A function that concatenates a list of values with the delimiter. |
merge_overlapping_strings(delimiter='\n', min_overlap=1, max_window=200)
Creates a function that merges a list of strings, handling common prefixes and overlaps.
The created function will: 1. Identify and remove any common prefix shared by the strings. 2. Process each pair of adjacent strings to remove overlapping strings. 3. Join the cleaned strings together, including the common prefix at the beginning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delimiter
|
str
|
The delimiter to use when merging the values. Defaults to "\n". |
'\n'
|
min_overlap
|
int
|
Minimum overlap length to consider valid. Defaults to 1. |
1
|
max_window
|
int
|
Maximum window size to search for overlaps. Defaults to 200. |
200
|
Returns:
| Type | Description |
|---|---|
Callable[[list[str]], str]
|
Callable[[list[str]], str]: A function that merges a list of strings, handling common prefixes and overlaps. |
pick_first(values)
Picks the first value from a list of values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
list[Any]
|
The values to pick from. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The first value from the list. |
pick_last(values)
Picks the last value from a list of values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
list[Any]
|
The values to pick from. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The last value from the list. |