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


Python Service.connectToDB方法代码示例

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


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

示例1: loadAuxiliaryData

# 需要导入模块: import Service [as 别名]
# 或者: from Service import connectToDB [as 别名]
def loadAuxiliaryData():
#	Service.logger.debug("Loading auxiliary data for terminology extraction system...")
	global ngramFilePath, adskUnwordsRoot
	global ngrams, nowords

#	ngrams = codecs.open(ngramFilePath, "r", "utf-8").read()
	conn = Service.connectToDB()
	cursor = conn.cursor()
	cursor.execute("select LangCode3Ltr from TargetLanguages")
	langs = cursor.fetchall()
	conn.close()
	for lang in langs:
		if __debug_on__:
			Service.logger.debug("\t\tReading nGram file " + ngramFilePath+"."+lang[0].upper()+".bz2...")
		ngrams[lang[0]] = bz2.BZ2File(ngramFilePath+"."+lang[0].upper()+".bz2", "r").read()

	# Load Autodesk-related lists:
	# - ngram-list (from Ventzi, including only the ngrams without counts)
	# - NeXLT product names (------ there is an N/A in it???)
	# - NeXLT language list
	# - city names from http://www.geodatasource.com/ and http://www.maxmind.com/en/worldcities
	# - words which should not be harvested (unwords and general words)
	# - Autodesk trademarks
	# - company names
	# Define nowords as filter
	nowords = preplists(adskUnwordsRoot+"/general_words.txt").union(preplists(adskUnwordsRoot+"/un_words.txt").union(preplists(adskUnwordsRoot+"/autodesk_trademarks.txt").union(preplists(adskUnwordsRoot+"/company_names.txt").union(preplists(adskUnwordsRoot+"/cities_regions.txt")))))
开发者ID:JongleurX,项目名称:Terminology,代码行数:28,代码来源:Extractor.py


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