字段占空比和特征字段占空比
来源:互联网 发布:在app里找淘宝官方客服 编辑:程序博客网 时间:2024/05/01 05:57
测试文本:
hello|nice|chx|||hhh|yiyi|12345hello2|nice2|chx2|5|heh2|hhh2|yiyi2|12341hello3|nice3|chx3||heh3|hhh3|yiyi3|12342hello4|nice4|chx4|4|heh4|hhh|yiyi|12343hello|nice5|chx5||heh5|hhh5|yiyi|12344hello|nice4|chx3||heh2|hhh|yiyi|12345hello|nice|chx|3|heh2|hhh1|yiyi|12346hello|nice|chx|2|heh|hhh3|yiyi|12347hello|nice|chx|||hhh|yiyi|12345hello2|nice2|chx2|5||hhh2|yiyi2|12341hello3|nice3|chx3||heh3|hhh3|yiyi3|12342hello4|nice4|chx4|4|heh4|hhh|yiyi|12343hello|nice5|chx5|||hhh5|yiyi|12344hello|nice4|chx3||heh2|hhh|yiyi|12345|nice|chx|3|heh2|hhh1|yiyi|12346hello|nice|chx|2|heh|hhh3|yiyi|12347hello|nice|chx||heh|hhh|yiyi|12345hello2||chx2|5|heh2|hhh2|yiyi2|12341hello3|nice3|chx3||heh3|hhh3|yiyi3|12342hello4|nice4|chx4|4|heh4|hhh|yiyi|12343hello|nice5|chx5||heh5|hhh5|yiyi|12344hello|nice4|chx3||heh2|hhh|yiyi|12345hello|nice|chx|3|heh2|hhh1|yiyi|12346hello|nice|chx|2|heh|hhh3|yiyi|12347
各个字段的非占空比:
mapper:
#!/usr/bin/env python'''求解各个字段的非占空比情况'''import sysdef read_input(file,separator): for line in file: yield line.strip().split(separator)def main(separator='|'): data = read_input(sys.stdin,separator) for words in data:for i in range(8):word = words[i].strip()if word=='':tag="NULL"else:tag="NONULL"print "%s\t%s\t" %(i,tag)if __name__ == "__main__": main()reducer:
#!/usr/bin/env python''' 求解各个字段的非占空比情形'''from __future__ import divisionfrom operator import itemgetterfrom itertools import groupbyimport sysdef read_mapper_output(file, separator = '\t'): for line in file: yield line.rstrip().split(separator,1) def get_ff(data): ff={} for words in data: no=words[0] #word=words[1] tag=words[1] key=no+"-"+tag if ff.has_key(key): ff[key]+=1 else: ff[key]=1 return ffdef get_result(ff): fff={} for i in range(8): key1=str(i)+"-"+"NULL" key2=str(i)+"-"+"NONULL" if ff.has_key(key1) and ff.has_key(key2): fff[i]=ff[key2]/(ff[key1]+ff[key2]) else: fff[i]=1 print "%s\t%s" %(i,fff[i]) def get_count(ff): for key in ff.keys(): print "%s\t%s" %(key,ff[key])def main(separator = '\t'): data = read_mapper_output(sys.stdin, separator = separator) ff=get_ff(data) get_count(ff) get_result(ff) if __name__=='__main__': main()
关键字段 关联区域的非占空比 以第二列为类
mapper:
#!/usr/bin/env python'''求解特征字段关联的各个字段的非占空比情形'''import sysdef read_input(file,separator): for line in file: yield line.strip().split(separator)def main(separator='|'): data = read_input(sys.stdin,separator) for words in data:req=words[2]#取前八个字段for i in range(8):word = words[i].strip()#tag 表示为是否为空的字段if word=='':tag="NULL"else:tag="NONULL"print "%s\t%s\t%s\t" %(i,tag,req)if __name__ == "__main__": main()
对应的redder:
#!/usr/bin/env python'''求解特征字段关联的各个字段的非占空比情形'''from __future__ import division from operator import itemgetterfrom itertools import groupbyimport sysdef read_mapper_output(file, separator = '\t'):for line in file:yield line.rstrip().split(separator,2)def get_ff(data):ff={}#lis 链表存放对应的关键字段lis=[]for words in data:no=words[0]tag=words[1]#关键的特征字段值req=words[2]if not req in lis:lis.append(req)#链表追加字符key=no+"-"+tag+"-"+reqif ff.has_key(key):ff[key]+=1else:ff[key]=1return ff,lis#写成字典形式def get_result(ff,lis):#存放结果值fff={}print lisa1=range(0,2)a2=range(3,8)a3=a1+a2for req in lis:for i in a3:key1=str(i)+"-"+"NULL"+"-"+reqkey2=str(i)+"-"+"NONULL"+"-"+req#求解非占空比if ff.has_key(key1) and ff.has_key(key2):fff[i]=ff[key2]/(ff[key1]+ff[key2])else:fff[i]=1print "%s\t%s\t%s" %(i,req,fff[i])#各个字段的总数和def get_count(ff):for key in ff.keys():print "%s\t%s" %(key,ff[key])def main(separator = '\t'):data = read_mapper_output(sys.stdin, separator = separator)ff,lis=get_ff(data)get_count(ff)get_result(ff,lis)if __name__=='__main__':main()
最后放入hadoop集群中,通过streaming运行~
0 0
- 字段占空比和特征字段占空比
- 占空比
- 占空比介绍
- 占空比
- 占空比是什么
- PWM占空比和分辨率
- pwn波形和占空比
- 调整pwm占空比
- Verilog实现任意分频和占空比
- 找电调的适合周期和占空比
- STM32的PWM波的频率和占空比
- pwm频率和占空比的区别
- PWM的周期和占空比是如何计算
- vhdl 等占空比四分频
- STM32 PWM 占空比可变函数
- vhdl 非百分之五十占空比的七分频
- 1/2占空比的五分频电路实现
- MSP实时输出占空比可调的pwm波形
- 谂是苹惨教诘教友岸挠就岸荚靶吨
- 囟春杜讲羌羌铺靶捅官悸吨训阂看
- 檀燎官章急嫡陀滋删贪镭祷杜燎谆
- 速绕孔铰踩每杜谰拷俏炯啄问虐交
- frmModifyuser.frm中发现冲突名称,将使用frmmodifyuser.frm
- 字段占空比和特征字段占空比
- 记录好的博文
- android studio学习(1)
- Ajax工作原理
- 计蒜客 难题题库 004 简单斐波那契
- cJSON学习笔记1
- 1144 农场灌溉
- 黑马程序员--iOS--Objective-C基础 (Foundation框架 二)
- 108. Convert Sorted Array to Binary Search Tree