帮助
|
留言交流
|
首 页
阅览室
馆友
我的图书馆
来自:
真实感vcderr4v
>
馆藏分类
配色:
字号:
大
中
小
word co-occurrence在Hadoop中得以实现
2018-03-22 | 阅:
转:
|
分享
14
15publicclassWCoextendsConfiguredimplementsTool{
16
17@Override
18publicintrun(String[]args)throwsException{
19
20if(args.length!=2){
21System.out.printf("Usage:hadoopjarwco.WCo
\n");
22return-1;
23}
24
25Jobjob=newJob(getConf());
26job.setJarByClass(WCo.class);
27job.setJobName("WordCoOccurrence");
28
29FileInputFormat.setInputPaths(job,newPath(args[0]));
30FileOutputFormat.setOutputPath(job,newPath(args[1]));
31
32job.setMapperClass(WCoMapper.class);
33job.setReducerClass(WCoReducer.class);
34
35job.setOutputKeyClass(Text.class);
36job.setOutputValueClass(IntWritable.class);
37
38booleansuccess=job.waitForCompletion(true);
39returnsuccess?0:1;
40}
41
42publicstaticvoidmain(String[]args)throwsException{
43intexitCode=ToolRunner.run(newConfiguration(),newWCo(),args);
44System.exit(exitCode);
45}
46}
算法的核心其实就是把前词和后词同时取出来作为key加上一个value做wordcount,统计单
词的共生频率来对文本进行聚类.看网上说k-means的很多,其实很多时候算法是根据需求走
的,k-means或者模糊k均值不一定就高大上,wordcount也不一定就穷矮矬.
献花(
0
)
+1
(本文系
真实感vcder...
首藏
)
类似文章
更多
多个mapreduce工作相互依赖处理方法完整实例(JobControl)
Hadoop学习之路(二十六)MapReduce的API使用(三)2
Hadoop MapReduce新旧API区别
How
MapReduce 实例浅析
MapReduce框架中全排序的算法思想
Hadoop学习之路(6)MapReduce自定义分区实现
hadoop setCombinerClass Combiner Reduce
MapReduce简单实例:wordcount--大数据纪录片第五记
发表评论: