20,808
社区成员
发帖
与我相关
我的任务
分享
public class TrainWork {
public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
Configuration conf = new Configuration();
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
if (otherArgs.length != 2) {
System.err.println("Usage: SplitWord <in> <out>");
System.exit(2);
}
conf.set("output", args[1]);
// 统计分类文档数和总文档数量
Job job = new Job(conf, "FileCount"); // 设置一个用户定义的job名称
job.setJarByClass(FileTotal.class);
job.setMapperClass(FileCountMapper.class); // 为job设置Mapper类
job.setReducerClass(FileCountReducer.class); // 为job设置Reducer类
job.setOutputKeyClass(Text.class); // 为job的输出数据设置Key类
job.setOutputValueClass(Text.class); // 为job输出设置value类
job.setInputFormatClass(TextInputFormat.class);
FileInputFormat.addInputPath(job, new Path(otherArgs[0])); // 为job设置输入路径
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1] + "/fileCount"));// 为job设置输出路径
// job.setNumReduceTasks(10);
job.waitForCompletion(true);
// 训练集
Job job1 = new Job(conf, "splitword"); // 设置一个用户定义的job名称
job1.setJarByClass(ModelTrain.class);
job1.setMapperClass(ModelTrainMapper.class); // 为job设置Mapper类
// job1.setCombinerClass(ModelTrainCombiner.class);
job1.setReducerClass(ModelTrainReducer.class); // 为job设置Reducer类
job1.setOutputKeyClass(Text.class); // 为job的输出数据设置Key类
job1.setOutputValueClass(Text.class); // 为job输出设置value类
job1.setInputFormatClass(TextInputFormat.class);
FileInputFormat.addInputPath(job1, new Path(otherArgs[0])); // 为job设置输入路径
FileOutputFormat.setOutputPath(job1, new Path(otherArgs[1] + "/splitWord"));// 为job设置输出路径
// job1.setNumReduceTasks(10);
job1.waitForCompletion(true);
}
}