本文整理汇总了Python中person.models.Person.find_prefix方法的典型用法代码示例。如果您正苦于以下问题:Python Person.find_prefix方法的具体用法?Python Person.find_prefix怎么用?Python Person.find_prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类person.models.Person
的用法示例。
在下文中一共展示了Person.find_prefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_find_name_prefix
# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import find_prefix [as 别名]
def test_find_name_prefix(self):
name = 'Ard van der Steur'
prefix, pos = Person.find_prefix(name)
self.assertEqual(prefix, 'van der')
name = 'Ard van derSteur'
prefix, pos = Person.find_prefix(name)
self.assertEqual(prefix, 'van')
name = 'Ard van de Steur'
prefix, pos = Person.find_prefix(name)
self.assertEqual(prefix, 'van de')
name = 'Ard van Steur'
prefix, pos = Person.find_prefix(name)
self.assertEqual(prefix, 'van')
name = 'Gerard \'t Hooft'
prefix, pos = Person.find_prefix(name)
self.assertEqual(prefix, '\'t')
name = 'Jan Peter Balkenende'
prefix, pos = Person.find_prefix(name)
self.assertEqual(prefix, '')
name = 'Boris van der Ham'
prefix, pos = Person.find_prefix(name)
self.assertEqual(prefix, 'van der')
name = 'van der Ham'
prefix, pos = Person.find_prefix(name)
self.assertEqual(prefix, 'van der')
name = 'van derHam'
prefix, pos = Person.find_prefix(name)
self.assertEqual(prefix, 'van')
name = 'von Martels'
prefix, pos = Person.find_prefix(name)
self.assertEqual(prefix, 'von')
示例2: parse_name_surname_initials
# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import find_prefix [as 别名]
def parse_name_surname_initials(name):
name = remove_forename(name)
name = name.replace(',', '')
initials = find_initials(name)
surname_prefix, pos = Person.find_prefix(name)
surname = name.replace(surname_prefix, '').replace(initials, '').replace(',', '').strip()
return initials, surname, surname_prefix