当前位置: 首页>>代码示例>>Python>>正文


Python UtilFunc.matchName方法代码示例

本文整理汇总了Python中UtilFunc.matchName方法的典型用法代码示例。如果您正苦于以下问题:Python UtilFunc.matchName方法的具体用法?Python UtilFunc.matchName怎么用?Python UtilFunc.matchName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UtilFunc的用法示例。


在下文中一共展示了UtilFunc.matchName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getNumberFromNameInFile

# 需要导入模块: import UtilFunc [as 别名]
# 或者: from UtilFunc import matchName [as 别名]
def getNumberFromNameInFile(name, yearbookReferenceFilePath):
	nameSep = re.findall('[A-Z][^A-Z]*',name)
	# print '### name:{0} nameSep: {1}'.format(name, nameSep)
	nameDict = {'WrittenLast':''.join(nameSep[0:-1]),'WrittenFirst':nameSep[-1]}
	yearbookNames = UtilFunc.parseDataFromFile(yearbookReferenceFilePath)
	jaroMatchIndex = UtilFunc.matchName(nameDict, yearbookNames)['AlphaIndex']

	return jaroMatchIndex
开发者ID:cdslug,项目名称:ClassmateMemory,代码行数:10,代码来源:ClassmateBatch.py

示例2: test_matchName_07

# 需要导入模块: import UtilFunc [as 别名]
# 或者: from UtilFunc import matchName [as 别名]
	def test_matchName_07(self):
		name = [{'WrittenLast':'Min','WrittenFirst':'Twins'},['Min','Nicolas'],None]
		returnValue = UtilFunc.matchName(name[0],self.refData,name[2])
		self.assertEqual([returnValue['YearbookLast'],returnValue['YearbookFirst']],name[1])
开发者ID:cdslug,项目名称:ClassmateMemory,代码行数:6,代码来源:TestScript.py

示例3: test_matchName_06

# 需要导入模块: import UtilFunc [as 别名]
# 或者: from UtilFunc import matchName [as 别名]
	def test_matchName_06(self):
		name = [{'WrittenLast':'Lunsford','WrittenFirst':'Erik-Scott'},['Lunsford','Erik-Scott'],0]
		returnValue = UtilFunc.matchName(name[0],self.refData,name[2])
		self.assertEqual([returnValue['YearbookLast'],returnValue['YearbookFirst']],name[1])
开发者ID:cdslug,项目名称:ClassmateMemory,代码行数:6,代码来源:TestScript.py

示例4: test_matchName_04

# 需要导入模块: import UtilFunc [as 别名]
# 或者: from UtilFunc import matchName [as 别名]
	def test_matchName_04(self):
		name = [{'WrittenLast':'MercerRyan','WrittenFirst':''},['Mercer','Ryan'],0]
		returnValue = UtilFunc.matchName(name[0],self.refData,name[2])
		self.assertEqual([returnValue['YearbookLast'],returnValue['YearbookFirst']],name[1])
开发者ID:cdslug,项目名称:ClassmateMemory,代码行数:6,代码来源:TestScript.py

示例5: indexList

# 需要导入模块: import UtilFunc [as 别名]
# 或者: from UtilFunc import matchName [as 别名]
def indexList(inputFilePath, inputCompleteFilePath, errorFilePath, yearbookReferenceFilePath, outputFilePath):

	names = []
	#list of dictionaries
	yearbookNames = UtilFunc.parseDataFromFile(yearbookReferenceFilePath)

	#list of dicitonaries
	namesOutput = []

	with open(inputFilePath, 'r') as fWN:
		for writtenIndex, line in enumerate(fWN):
			#could have been simpler, but sometimes last names are not included
			#may have to worry about only last name. Spell checker will reject that
			# lineSplit = line.replace('\n','').split(None,1)[::-1]
			lineSplit = line.replace('\n','').split(None,1)
			l0 = lineSplit[0]
			l1 = ''
			if len(lineSplit) > 1:
				l1 = lineSplit[1]
			else:
				l1 = '_'
			names.append({	'WrittenIndex':str(writtenIndex),
							'WrittenFirst':l0,
							'WrittenLast':l1})

	# with open(yearbookNamesFile, 'r') as fYBN:
	# 	for index, line in enumerate(fYBN):
	# 		#Skip the heading
	# 		if index > 0:
	# 			(l0,l1,l2,l3) = line.replace('\r','').replace('\n','').split(',')
	# 			yearbookNames.append({	'AlphaIndex':l0,
	# 									'YearbookLast':l1,
	# 									'YearbookFirst':l2,
	# 									'GraduatedLLA09':l3})


	namesOutput = []
	for name in names:
		jaroMatch = UtilFunc.matchName(name, yearbookNames)
		namesOutput.append(jaroMatch)

	# for n in namesOutput: #debugging
	# 	print(str(n) + '\n')

	#append missing names
	for ybn in yearbookNames:
		if ybn['AlphaIndex'] not in [no['AlphaIndex'] for no in namesOutput]:
			temp = ybn.copy()
			temp.update({	'WrittenIndex':'-',
							'WrittenLast':'',
							'WrittenFirst':'', 
							'Spelling':str(0)})
			namesOutput.append(temp)

	with open(outputFilePath,'w') as fOut:
		fOut.write('AlphaIndex,WrittenIndex,WrittenLast,WrittenFirst,YearbookLast,YearbookFirst,Spelling,GraduatedLLA09\n')
		for no in namesOutput:
			fOut.write('{},{},{},{},{},{},{},{}\n'.format(	no['AlphaIndex'],
				   											no['WrittenIndex'],
				   											no['WrittenLast'],
				   											no['WrittenFirst'],
				   											no['YearbookLast'],
				   											no['YearbookFirst'],
				   											no['Spelling'],
				   											no['GraduatedLLA09']))

	shutil.copy(inputFilePath,inputCompleteFilePath)
	os.remove(inputFilePath)
	return
开发者ID:cdslug,项目名称:ClassmateMemory,代码行数:71,代码来源:IndexList.py


注:本文中的UtilFunc.matchName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。