本文整理匯總了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")))))