本文整理汇总了Python中fuzzywuzzy.string_processing.StringProcessor.replace_non_lettters_non_numbers_with_whitespace方法的典型用法代码示例。如果您正苦于以下问题:Python StringProcessor.replace_non_lettters_non_numbers_with_whitespace方法的具体用法?Python StringProcessor.replace_non_lettters_non_numbers_with_whitespace怎么用?Python StringProcessor.replace_non_lettters_non_numbers_with_whitespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fuzzywuzzy.string_processing.StringProcessor
的用法示例。
在下文中一共展示了StringProcessor.replace_non_lettters_non_numbers_with_whitespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_replace_non_lettters_non_numbers_with_whitespace
# 需要导入模块: from fuzzywuzzy.string_processing import StringProcessor [as 别名]
# 或者: from fuzzywuzzy.string_processing.StringProcessor import replace_non_lettters_non_numbers_with_whitespace [as 别名]
def test_replace_non_lettters_non_numbers_with_whitespace(self):
strings = ["new york mets - atlanta braves", "Cães danados", "New York //// Mets $$$", "Ça va?"]
for string in strings:
proc_string = StringProcessor.replace_non_lettters_non_numbers_with_whitespace(string)
regex = re.compile(r"(?ui)[\W]")
for expr in regex.finditer(proc_string):
self.assertEquals(expr.group(), " ")
示例2: full_process
# 需要导入模块: from fuzzywuzzy.string_processing import StringProcessor [as 别名]
# 或者: from fuzzywuzzy.string_processing.StringProcessor import replace_non_lettters_non_numbers_with_whitespace [as 别名]
def full_process(s, force_ascii=False):
"""Process string by
-- removing all but letters and numbers
-- trim whitespace
-- force to lower case
if force_ascii == True, force convert to ascii"""
if s is None:
return ""
if force_ascii:
s = asciidammit(s)
# Keep only Letters and Numbres (see Unicode docs).
string_out = StringProcessor.replace_non_lettters_non_numbers_with_whitespace(s)
# Force into lowercase.
string_out = StringProcessor.to_lower_case(string_out)
# Remove leading and trailing whitespaces.
string_out = StringProcessor.strip(string_out)
return string_out
示例3: test_dont_condense_whitespace
# 需要导入模块: from fuzzywuzzy.string_processing import StringProcessor [as 别名]
# 或者: from fuzzywuzzy.string_processing.StringProcessor import replace_non_lettters_non_numbers_with_whitespace [as 别名]
def test_dont_condense_whitespace(self):
s1 = "new york mets - atlanta braves"
s2 = "new york mets atlanta braves"
p1 = StringProcessor.replace_non_lettters_non_numbers_with_whitespace(s1)
p2 = StringProcessor.replace_non_lettters_non_numbers_with_whitespace(s2)
self.assertNotEqual(p1, p2)