Modules
stringpod
¶
Main module.
contains_chinese(text)
¶
Check if the text contains Chinese characters.
Example:
contains_chinese('你好,世界!') True contains_chinese('Hello, world!') False
Source code in stringpod/stringpod.py
10 11 12 13 14 15 16 17 18 19 |
|
contains_email(text)
¶
Check if the text contains an email.
Example:
contains_email('test@example.com') True contains_email('test@example.com.tw') True contains_email('test@example') False
Source code in stringpod/stringpod.py
110 111 112 113 114 115 116 117 118 119 120 121 |
|
contains_english(text)
¶
Check if the text contains English characters.
Example:
contains_english('Hello, world!') True contains_english('你好,世界!') False contains_english('HelloWorld') True
Source code in stringpod/stringpod.py
22 23 24 25 26 27 28 29 30 31 32 33 |
|
contains_number(text)
¶
Check if the text contains numbers.
Example:
contains_number('Hello, world!') False contains_number('你好,世界!') False contains_number('你好123') True
Source code in stringpod/stringpod.py
36 37 38 39 40 41 42 43 44 45 46 47 |
|
contains_punctuation(text)
¶
Check if the text contains punctuation.
Example:
contains_punctuation('Hello, world!') True contains_punctuation('你好,世界!') True contains_punctuation('你好世界') False
Source code in stringpod/stringpod.py
50 51 52 53 54 55 56 57 58 59 60 61 |
|
contains_special_character(text)
¶
Check if the text contains special characters.
Example:
contains_special_character('Hello,world!') True contains_special_character('Helloworld!') True contains_special_character('Hello World') False contains_special_character('HelloWorld') False
Source code in stringpod/stringpod.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
contains_substring(text, substring, options=None)
¶
Check if the text contains a substring.
Text will undergo the following transformations before checking: - Normalize to lowercase - Remove whitespace - Remove punctuation - Remove special characters - Romanize Chinese characters
The following will be checked: - Traditional and Simplified Chinese (If the substring is in Traditional Chinese, it will also be checked in Simplified Chinese)
Example:
contains_substring('你好,世界!', '你好') True options = NormalizerOptions(ignore_chinese_variant=True) contains_substring('計算機', '计算', options) True options_all = NormalizerOptions.enable_all() contains_substring('計算機', 'Ji', options_all) False
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to check |
required |
substring
|
str
|
The substring to check for |
required |
options
|
NormalizerOptions | None
|
Normalization options to apply |
None
|
Returns:
Type | Description |
---|---|
bool
|
True if the text contains the substring, False otherwise |
Source code in stringpod/stringpod.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
contains_url(text)
¶
Check if the text contains a URL.
Example:
contains_url('https://www.google.com') True contains_url('http://www.google.com') True contains_url('www.google.com') False contains_url('google.com') False
Source code in stringpod/stringpod.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
contains_whitespace(text)
¶
Check if the text contains whitespace.
Example:
contains_whitespace('Hello, world!') True contains_whitespace('Hello world!') True contains_whitespace('HelloWorld!') False
Source code in stringpod/stringpod.py
80 81 82 83 84 85 86 87 88 89 90 91 |
|