SAIM - Strain Authentication and Identification Methods#
parse
#
string
#
clean_string(text, /, *pattern_args)
#
Removes all occurrences of one or multiple regex patterns from a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input string to clean. |
required |
*pattern_args
|
Pattern[str]
|
One or more compiled regex patterns to remove from the string. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The cleaned string with all occurrences of the given patterns replaced by an empty string. |
Source code in src/saim/shared/parse/string.py
search
#
radix_tree
#
RadixTree
#
Creates a radix tree by splitting a string into nodes forming a prefix hierarchy.
Each node contains a mapping (con) of characters to child RadixTree nodes,
representing the next character in the string. The splitting continues
until the end of the string, indicated by end == True.
For example, the string 'ABC#$' is stored as:
RadixTree('ABC#$') -> con = { 'A': RadixTree('BC#$') }
RadixTree('BC#$') -> con = { 'B': RadixTree('C#$') }
RadixTree('C#$') -> con = { 'C': RadixTree('#$') }
RadixTree('#$') -> con = { ':': RadixTree('$') }
RadixTree('$') -> con = { ':': RadixTree() }, end == True
Attributes:
| Name | Type | Description |
|---|---|---|
con |
tuple[_RQP[T], ...]
|
Child nodes keyed by character. |
end |
bool
|
True if this node represents the end of a word. |
index |
tuple[T, ...]
|
Associated index or data for this node. |
max |
int
|
The maximum length of a substring key among this node's immediate children.. |
ready |
bool
|
Flag indicating if the node is ready (compact implementation of a prefix tree). |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
init
|
str
|
The initial string to build the radix tree node from. |
required |
index
|
tuple[T, ...]
|
Tuple of associated data or index values. |
required |