本文整理汇总了Python中DB.get_con方法的典型用法代码示例。如果您正苦于以下问题:Python DB.get_con方法的具体用法?Python DB.get_con怎么用?Python DB.get_con使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB.get_con方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _calculate_word_scores
# 需要导入模块: import DB [as 别名]
# 或者: from DB import get_con [as 别名]
def _calculate_word_scores(self, phrase_list):
word_freq = nltk.FreqDist()
for phrase in phrase_list:
for word in phrase:
if not isNumeric(word) and len(word)>1:
word_freq[wn.morphy(word)] += 1
word_scores = {}
uniqTerms = word_freq.keys()
con = DB.get_con()
for word in uniqTerms:
word_scores[word] = self._calculate_tf_idf(word,word_freq,con)
return word_scores
示例2: _getSources
# 需要导入模块: import DB [as 别名]
# 或者: from DB import get_con [as 别名]
def _getSources():
all_word_lists = []
for i,f in enumerate(docs_list):
with open(f, 'r') as file:
text = file.read().lower()
text = removeNonAscii(text)
# text = unicode(text , errors='ignore')
sentences = nltk.sent_tokenize(text)
#print self._generate_word_list(sentences)
current_doc_uniq_word_list = list(set(_generate_word_list(sentences)))
con = DB.get_con()
for w in current_doc_uniq_word_list:
if not isNumeric(w) and len(w)>1:
DB.incr_occurrence(w,con)
DB.incr_total_doc_number(con)
con.close()
file.close()
return all_word_lists