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


Python Tools.calc_median方法代码示例

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


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

示例1: generate_stats

# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import calc_median [as 别名]
	def generate_stats(self):
		spkwhole = SpeakerStatistics("whole")
		self.statistics["whole"]=spkwhole
		for spc in self.get_speech_list():
			self.statistics["whole"].add_speech(spc.get_length())
			#check if the speakers all have the dot so we don't get the same speaker doubled.
			if "." in spc.get_speaker():
				speaker = spc.get_speaker()
			else:
				speaker = spc.get_speaker() + "."

			if(speaker not in self.statistics):
				spkstat = SpeakerStatistics(speaker)
				spkstat.add_speech(spc.get_length())
				self.statistics[speaker] = spkstat
			else:
				spkstat = self.statistics[speaker]
				spkstat.add_speech(spc.get_length())
		#the medium and mean count for the whole text
		for key,value in self.statistics.items():
			if(key!="whole"):
				self.counts.append(value.get_count())
		tools = Tools()
		self.median_count = tools.calc_median(self.counts)
		self.average_count = tools.calc_average(tools.calc_sum(self.counts),len(self.counts))
开发者ID:kstoltzenburg,项目名称:teireader,代码行数:27,代码来源:speech.py

示例2: generate_stats

# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import calc_median [as 别名]
	def generate_stats(self):
		word_count = 0
		pause = False
		spkwhole = SpeakerStatistics("whole")
		self.statistics["whole"]=spkwhole
		for spc in self.get_speech_list():
			self.statistics["whole"].add_speech(spc.get_length())
			#five hundred span and 10 pause
			for words in spc.get_words_array():
				word_count = word_count + 1
			if (word_count % 500 == 0):
				word_count = 0
				pause = True
			if(word_count == 10 and pause == True):
				pause = False
				word_count = 0
			if "." in spc.get_speaker():
				speaker = spc.get_speaker()
			else:
				speaker = spc.get_speaker() + "."
			if(pause != True):
				if(speaker not in self.statistics):
					spkstat = SpeakerStatistics(speaker)
					spkstat.add_speech(spc.get_length())
					self.statistics[speaker] = spkstat
				else:
					spkstat = self.statistics[speaker]
					spkstat.add_speech(spc.get_length())
		#the medium and mean count for the whole text
		for key,value in self.statistics.items():
			if(key!="whole"):
				self.counts.append(value.get_count())
		tools = Tools()
		self.median_count = tools.calc_median(self.counts)
		self.average_count = tools.calc_average(tools.calc_sum(self.counts),len(self.counts))
开发者ID:kstoltzenburg,项目名称:teireader,代码行数:37,代码来源:speech.py

示例3: set_median

# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import calc_median [as 别名]
	def set_median(self):
		tools = Tools()
		values = self.get_speech_length()
		self.median = tools.calc_median(values)
开发者ID:kstoltzenburg,项目名称:teireader,代码行数:6,代码来源:speech.py


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