Cambridge SMT System
PhraseJob.java
Go to the documentation of this file.
1 /*******************************************************************************
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use these files except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  *
14  *******************************************************************************/
15 
16 package uk.ac.cam.eng.extraction.hadoop.features.phrase;
17 
18 import java.io.IOException;
19 
20 import org.apache.hadoop.conf.Configuration;
21 import org.apache.hadoop.conf.Configured;
22 import org.apache.hadoop.fs.Path;
23 import org.apache.hadoop.mapreduce.Job;
24 import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
25 import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
26 import org.apache.hadoop.util.Tool;
27 
29 import uk.ac.cam.eng.util.CLI;
30 
31 import com.beust.jcommander.ParameterException;
32 
39 public abstract class PhraseJob extends Configured implements Tool {
40 
41  public abstract Job getJob(Configuration conf) throws IOException;
42 
43  @Override
44  public int run(String[] args) throws IllegalArgumentException,
45  IllegalAccessException, IOException, ClassNotFoundException,
46  InterruptedException {
48  try {
49  Util.parseCommandLine(args, params);
50  } catch (ParameterException e) {
51  return 1;
52  }
53  Configuration conf = getConf();
54  Util.ApplyConf(params, conf);
55  Job job = getJob(conf);
56  FileInputFormat.setInputPaths(job, params.input);
57  FileOutputFormat.setOutputPath(job, new Path(params.output));
58  return job.waitForCompletion(true) ? 0 : 1;
59  }
60 }
static void ApplyConf(Object params, Configuration conf)
Definition: Util.java:80
static JCommander parseCommandLine(String[] args, Object params)
Definition: Util.java:85