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


Python Corpus.buildCorpusOnDB方法代码示例

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


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

示例1: generateData

# 需要导入模块: from corpus import Corpus [as 别名]
# 或者: from corpus.Corpus import buildCorpusOnDB [as 别名]
def generateData():
	rep = Representor(None, 'citybeat', 'next_week_candidate_event_25by25_merged')
	corpus = Corpus()
	corpus.buildCorpusOnDB('citybeat', 'next_week_candidate_event_25by25_merged')
	true_event_list, false_event_list = loadNextWeekData()
	EventFeatureTwitter(None).GenerateArffFileHeader()
		
	for event in true_event_list + false_event_list:
		EventFeatureTwitter(event, corpus, rep).printFeatures()
开发者ID:daifanxiang,项目名称:CityBeat,代码行数:11,代码来源:process_data_next_week.py

示例2: generateData2

# 需要导入模块: from corpus import Corpus [as 别名]
# 或者: from corpus.Corpus import buildCorpusOnDB [as 别名]
def generateData2(_182, sparse=False):
#	if sparse:
	rep = Representor()
	corpus = Corpus()
	corpus.buildCorpusOnDB('citybeat', 'candidate_event_25by25_merged')
	
	true_event_list, false_event_list = loadUnbalancedData(_182)

	if sparse:
		word_index, word_list = getCorpusWordList(rep, true_event_list + false_event_list)
		EventFeatureSparse(None).GenerateArffFileHeader(word_list)
	else:
		EventFeatureTwitter(None).GenerateArffFileHeader()
		
	for event in true_event_list + false_event_list:
		if not sparse:
			EventFeatureTwitter(event, corpus, rep).printFeatures()
		else:
			EventFeatureSparse(event, corpus, rep).printFeatures(word_index)
开发者ID:daifanxiang,项目名称:CityBeat,代码行数:21,代码来源:process_data.py

示例3: min

# 需要导入模块: from corpus import Corpus [as 别名]
# 或者: from corpus.Corpus import buildCorpusOnDB [as 别名]
			k = min(len(photos), k)
			# discard the keywords with only one photo
#			if k == 1:
#				break
			res.append([word, fre, photos[0:k]])
		return res
	
	def getTopKeywordsAndPhotos(self, num_keywords, num_photos):
		keywords = self._getTopKeywordsWithoutStopwords(num_keywords)
		return self._getRandomPhotosAssociatedWithKeywords(keywords, num_photos)
	
	def getTopKeywordsAndPhotosByTFIDF(self, num_keywords, num_photos):
		keywords = self._getTopKeywordsWithoutStopwords(100000)
		keywords = self._corpus.chooseTopWordWithHighestTDIDF(keywords, num_keywords)
		return self._getRandomPhotosAssociatedWithKeywords(keywords, num_photos)
			
if __name__=='__main__':
	
	collection = 'candidate_event_10by10_merged'
	
	c = Corpus()
	c.buildCorpusOnDB('citybeat', collection)
	
	ei = EventInterface()
	ei.setDB('citybeat')
	ei.setCollection(collection)
	events = ei.getAllDocuments()
	for event in events:
		event = EventFrontend(event, c)
		print event.getTopKeywordsAndPhotosByTFIDF(10,0)
开发者ID:daifanxiang,项目名称:CityBeat,代码行数:32,代码来源:event_frontend.py


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