List of usage examples for org.apache.mahout.classifier.naivebayes BayesUtils writeLabelIndex
public static int writeLabelIndex(Configuration conf, Path indexPath, Iterable<Pair<Text, IntWritable>> labels) throws IOException
From source file:com.netease.news.classifier.naivebayes.TrainNaiveBayesJob.java
License:Apache License
private long createLabelIndex(Path labPath) throws IOException { long labelSize = 0; if (hasOption(LABELS)) { Iterable<String> labels = Splitter.on(",").split(getOption(LABELS)); labelSize = BayesUtils.writeLabelIndex(getConf(), labels, labPath); } else if (hasOption(EXTRACT_LABELS)) { Iterable<Pair<Text, IntWritable>> iterable = new SequenceFileDirIterable<Text, IntWritable>( getInputPath(), PathType.LIST, PathFilters.logsCRCFilter(), getConf()); labelSize = BayesUtils.writeLabelIndex(getConf(), labPath, iterable); }//from www . j av a2s .com return labelSize; }