// Path: src/edu/jhu/thrax/hadoop/jobs/ExtractionJob.java
// public class ExtractionJob implements ThraxJob {
// 
//   public Set<Class<? extends ThraxJob>> getPrerequisites() {
//     Set<Class<? extends ThraxJob>> result = new HashSet<Class<? extends ThraxJob>>();
//     result.add(VocabularyJob.class);
//     return result;
//   }
// 
//   public Job getJob(Configuration conf) throws IOException {
//     Job job = new Job(conf, "extraction");
//     job.setJarByClass(ExtractionMapper.class);
// 
//     job.setMapperClass(ExtractionMapper.class);
//     job.setCombinerClass(ExtractionCombiner.class);
//     job.setReducerClass(ExtractionReducer.class);
// 
//     job.setSortComparatorClass(AlignedRuleWritable.RuleYieldComparator.class);
//     job.setPartitionerClass(AlignedRuleWritable.RuleYieldPartitioner.class);
//     
//     job.setMapOutputKeyClass(AlignedRuleWritable.class);
//     job.setMapOutputValueClass(Annotation.class);
//     job.setOutputKeyClass(RuleWritable.class);
//     job.setOutputValueClass(Annotation.class);
// 
//     job.setOutputFormatClass(SequenceFileOutputFormat.class);
// 
//     int numReducers = conf.getInt("thrax.reducers", 4);
//     job.setNumReduceTasks(numReducers);
// 
//     FileInputFormat.setInputPaths(job, new Path(conf.get("thrax.input-file")));
//     int maxSplitSize = conf.getInt("thrax.max-split-size", 0);
//     if (maxSplitSize != 0) FileInputFormat.setMaxInputSplitSize(job, maxSplitSize);
// 
//     FileOutputFormat.setOutputPath(job, new Path(conf.get("thrax.work-dir") + "rules"));
// 
//     return job;
//   }
// 
//   // TODO: unify names of jobs and their output directories
// 
//   public String getName() {
//     return "extraction";
//   }
// 
//   public String getOutputSuffix() {
//     return "rules";
//   }
// }


import java.io.IOException;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparator;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Partitioner;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
import org.apache.hadoop.mapreduce.lib.reduce.IntSumReducer;
import edu.jhu.thrax.hadoop.datatypes.FeaturePair;
import edu.jhu.thrax.hadoop.datatypes.RuleWritable;
import edu.jhu.thrax.hadoop.features.Feature;
import edu.jhu.thrax.hadoop.jobs.ExtractionJob;
import edu.jhu.thrax.hadoop.jobs.ThraxJob;
package edu.jhu.thrax.hadoop.features.mapred;




@SuppressWarnings("rawtypes")
public abstract class MapReduceFeature implements Feature, ThraxJob {
  
  public String getOutputSuffix() {
    return getName();
  }

  public Class<? extends Reducer> combinerClass() {
    return IntSumReducer.class;
  }

  public abstract Class<? extends Mapper> mapperClass();

  public abstract Class<? extends WritableComparator> sortComparatorClass();

  public abstract Class<? extends Partitioner> partitionerClass();

  public abstract Class<? extends Reducer> reducerClass();

  public Job getJob(Configuration conf) throws IOException {
    String name = getName();
    Job job = new Job(conf, name);
    job.setJarByClass(this.getClass());

    job.setMapperClass(this.mapperClass());
    job.setCombinerClass(this.combinerClass());
    job.setSortComparatorClass(this.sortComparatorClass());
    job.setPartitionerClass(this.partitionerClass());
// Path: src/edu/jhu/thrax/hadoop/jobs/ExtractionJob.java
// public class ExtractionJob implements ThraxJob {
// 
//   public Set<Class<? extends ThraxJob>> getPrerequisites() {
//     Set<Class<? extends ThraxJob>> result = new HashSet<Class<? extends ThraxJob>>();
//     result.add(VocabularyJob.class);
//     return result;
//   }
// 
//   public Job getJob(Configuration conf) throws IOException {
//     Job job = new Job(conf, "extraction");
//     job.setJarByClass(ExtractionMapper.class);
// 
//     job.setMapperClass(ExtractionMapper.class);
//     job.setCombinerClass(ExtractionCombiner.class);
//     job.setReducerClass(ExtractionReducer.class);
// 
//     job.setSortComparatorClass(AlignedRuleWritable.RuleYieldComparator.class);
//     job.setPartitionerClass(AlignedRuleWritable.RuleYieldPartitioner.class);
//     
//     job.setMapOutputKeyClass(AlignedRuleWritable.class);
//     job.setMapOutputValueClass(Annotation.class);
//     job.setOutputKeyClass(RuleWritable.class);
//     job.setOutputValueClass(Annotation.class);
// 
//     job.setOutputFormatClass(SequenceFileOutputFormat.class);
// 
//     int numReducers = conf.getInt("thrax.reducers", 4);
//     job.setNumReduceTasks(numReducers);
// 
//     FileInputFormat.setInputPaths(job, new Path(conf.get("thrax.input-file")));
//     int maxSplitSize = conf.getInt("thrax.max-split-size", 0);
//     if (maxSplitSize != 0) FileInputFormat.setMaxInputSplitSize(job, maxSplitSize);
// 
//     FileOutputFormat.setOutputPath(job, new Path(conf.get("thrax.work-dir") + "rules"));
// 
//     return job;
//   }
// 
//   // TODO: unify names of jobs and their output directories
// 
//   public String getName() {
//     return "extraction";
//   }
// 
//   public String getOutputSuffix() {
//     return "rules";
//   }
// }


// Path: src/edu/jhu/thrax/hadoop/features/mapred/MapReduceFeature.java
import java.io.IOException;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparator;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Partitioner;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
import org.apache.hadoop.mapreduce.lib.reduce.IntSumReducer;
import edu.jhu.thrax.hadoop.datatypes.FeaturePair;
import edu.jhu.thrax.hadoop.datatypes.RuleWritable;
import edu.jhu.thrax.hadoop.features.Feature;
import edu.jhu.thrax.hadoop.jobs.ExtractionJob;
import edu.jhu.thrax.hadoop.jobs.ThraxJob;

package edu.jhu.thrax.hadoop.features.mapred;




@SuppressWarnings("rawtypes")
public abstract class MapReduceFeature implements Feature, ThraxJob {
  
  public String getOutputSuffix() {
    return getName();
  }

  public Class<? extends Reducer> combinerClass() {
    return IntSumReducer.class;
  }

  public abstract Class<? extends Mapper> mapperClass();

  public abstract Class<? extends WritableComparator> sortComparatorClass();

  public abstract Class<? extends Partitioner> partitionerClass();

  public abstract Class<? extends Reducer> reducerClass();

  public Job getJob(Configuration conf) throws IOException {
    String name = getName();
    Job job = new Job(conf, name);
    job.setJarByClass(this.getClass());

    job.setMapperClass(this.mapperClass());
    job.setCombinerClass(this.combinerClass());
    job.setSortComparatorClass(this.sortComparatorClass());
    job.setPartitionerClass(this.partitionerClass());
    job.setReducerClass(this.reducerClass());