<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.huahinframework.core;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.util.ToolRunner;

/**
 * Execution of the job can be done easily and use this class.
 *
 * <p>Example:</p>
 * <p><blockquote><pre>
 * public class Jobs {
 *   public static void main(String[] args) {
 *      String jobName = args[0];
 *      String[] newArgs = new String[args.length - 1];
 *      for (int i = 1; i < args.length; ++i) {
 *          newArgs[i - 1] = args[i];
 *      }
 *
 *     Runner runner = new Runner();
 *     runner.addJob("WordCount", WordCount.class);
 *     runner.addJob("Grep", Grep.class);
 *
 *     int status = runner.run(jobName, args);
 *
 *     System.exit(status);
 *   }
 * }
 * </pre></blockquote></p>
 */
public class Runner {
    private static final Log log = LogFactory.getLog(Runner.class);

    private Map<String, Class<? extends SimpleJobTool>> jobMap =
            new HashMap<String, Class<? extends SimpleJobTool>>();

    /**
     * Run the job.
     * @param jobName running job sequence name
     * @param args job parameters
     * @return job status
     */
    public int run(String jobName, String[] args) {
        int status = -1;

        try {
            status =  ToolRunner.run(jobMap.get(jobName).newInstance(), args);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e);
        }

        return status;
    }

    /**
     * Add job sequence.
     * @param name job sequence name
     * @param clazz SimpleJobTool class
     */
    public void addJob(String name, Class<? extends SimpleJobTool> clazz) {
        jobMap.put(name, clazz);
    }
}<commit_msg>update Runnner not Tool class<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.huahinframework.core;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;

/**
 * Execution of the job can be done easily and use this class.
 *
 * <p>Example:</p>
 * <p><blockquote><pre>
 * public class Jobs {
 *   public static void main(String[] args) {
 *      String jobName = args[0];
 *      String[] newArgs = new String[args.length - 1];
 *      for (int i = 1; i < args.length; ++i) {
 *          newArgs[i - 1] = args[i];
 *      }
 *
 *     Runner runner = new Runner();
 *     runner.addJob("WordCount", WordCount.class);
 *     runner.addJob("Grep", Grep.class);
 *
 *     int status = runner.run(jobName, args);
 *
 *     System.exit(status);
 *   }
 * }
 * </pre></blockquote></p>
 */
public class Runner {
    private static final Log log = LogFactory.getLog(Runner.class);

    private Map<String, Class<? extends SimpleJobTool>> jobMap =
            new HashMap<String, Class<? extends SimpleJobTool>>();

    /**
     * Run the job.
     * @param jobName running job sequence name
     * @param args job parameters
     * @return job status
     */
    public int run(String jobName, String[] args) {
        int status = -1;

        try {
            Class<? extends Tool> clazz = jobMap.get(jobName);
            if (clazz == null) {
                log.error("Tool class not found.");
                return status;
            }
            status =  ToolRunner.run(clazz.newInstance(), args);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e);
        }

        return status;
    }

    /**
     * Add job sequence.
     * @param name job sequence name
     * @param clazz SimpleJobTool class
     */
    public void addJob(String name, Class<? extends SimpleJobTool> clazz) {
        jobMap.put(name, clazz);
    }
}
{'fraction_non_alphanumeric': 0.11183355006501951, 'fraction_numerical': 0.0033438603009474273, 'mean_word_length': 2.675085324232082, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '524085', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1511, 'n_words': 534}