本文整理匯總了Python中normality.normalize方法的典型用法代碼示例。如果您正苦於以下問題:Python normality.normalize方法的具體用法?Python normality.normalize怎麽用?Python normality.normalize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類normality
的用法示例。
在下文中一共展示了normality.normalize方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: make_csv_file_name
# 需要導入模塊: import normality [as 別名]
# 或者: from normality import normalize [as 別名]
def make_csv_file_name(meta, table, out_folder):
bank_name = normalize(meta['BankName'], lowercase=False)
if bank_name is None:
bank_name = 'Untitled Database'
table_abbr = normalize(table['abbr'], lowercase=False)
table_name = normalize(table['name'], lowercase=False)
file_name = '%s - %s - %s.csv' % (bank_name, table_abbr, table_name)
return os.path.join(out_folder, file_name)
示例2: test_empty
# 需要導入模塊: import normality [as 別名]
# 或者: from normality import normalize [as 別名]
def test_empty(self):
self.assertEqual(None, slugify(None))
self.assertEqual(None, ascii_text(None))
self.assertEqual(None, latinize_text(None))
self.assertEqual(None, normalize(None))
self.assertEqual(None, normalize(''))
self.assertEqual(None, normalize(' '))
示例3: test_petro
# 需要導入模塊: import normality [as 別名]
# 或者: from normality import normalize [as 別名]
def test_petro(self):
text = u'Порошенко Петро Олексійович'
self.assertEqual('porosenko-petro-oleksijovic', slugify(text))
self.assertEqual('Porosenko Petro Oleksijovic', ascii_text(text))
self.assertEqual(u'Porošenko Petro Oleksíjovič', latinize_text(text))
self.assertEqual(u'порошенко петро олексіиович', normalize(text))
示例4: clean
# 需要導入模塊: import normality [as 別名]
# 或者: from normality import normalize [as 別名]
def clean(mapping, bind, values):
""" Perform several types of string cleaning for titles etc.. """
categories = {'C': ' '}
for value in values:
if isinstance(value, six.string_types):
value = normality.normalize(value, lowercase=False, collapse=True,
decompose=False,
replace_categories=categories)
yield value
示例5: normalize
# 需要導入模塊: import normality [as 別名]
# 或者: from normality import normalize [as 別名]
def normalize(self, text, **kwargs):
"""Normalize for comparison."""
ids = super(IdentifierType, self).normalize(text, **kwargs)
return [normalize(i) for i in ids]
示例6: compare_names
# 需要導入模塊: import normality [as 別名]
# 或者: from normality import normalize [as 別名]
def compare_names(left, right):
result = 0
left_list = [normalize(n, latinize=True) for n in left.names]
right_list = [normalize(n, latinize=True) for n in right.names]
for (left, right) in itertools.product(left_list, right_list):
similarity = jaro(left, right)
score = similarity * dampen(2, 20, shortest(left, right))
result = max(result, score)
return result