str_utils
sc_crawler.str_utils
#
Functions:
| Name | Description |
|---|---|
wrap |
Wrap string between before/after strings (default to spaces) if not empty. |
space_after |
Add space after string if not empty. |
snake_case |
Convert CamelCase to snake_case. |
plural |
Super basic implementation of pluralizing an English word. |
extract_last_number |
Extract the last non-negative number from a string. |
wrap
#
Wrap string between before/after strings (default to spaces) if not empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
A string. |
required |
before
|
str
|
Characters to be added before the |
' '
|
after
|
str
|
Characters to be added after the |
' '
|
Source code in sc_crawler/str_utils.py
space_after
#
snake_case
#
plural
#
Super basic implementation of pluralizing an English word.
Note that grammar exceptions are not handled, so better to use a proper NLP method for real use-cases.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
A singular noun. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Plural form of the noun. |
Examples:
Source code in sc_crawler/str_utils.py
extract_last_number
#
Extract the last non-negative number from a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input string from which to extract the number. |
required |
Returns:
| Type | Description |
|---|---|
Union[float, None]
|
The last non-negative number found in the string, or None if no number is found. |
Examples: