本文整理汇总了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")))))