Example usage for org.apache.commons.cli CommandLine getOptions

List of usage examples for org.apache.commons.cli CommandLine getOptions

Introduction

In this page you can find the example usage for org.apache.commons.cli CommandLine getOptions.

Prototype

public Option[] getOptions() 

Source Link

Document

Returns an array of the processed Option s.

Usage

From source file:org.wikidata.wdtk.client.ClientConfiguration.java

/**
 * Analyses the command-line arguments which are relevant for the specific
 * action that is to be executed, and returns a corresponding
 * {@link DumpProcessingAction} object.//from  w w  w. java2  s.  c  om
 * 
 * @param cmd
 *            {@link CommandLine} objects; contains the command line
 *            arguments parsed by a {@link CommandLineParser}
 * @return {@link DumpProcessingAction} for the given arguments
 */
private DumpProcessingAction handleActionArguments(CommandLine cmd) {

    DumpProcessingAction result = makeDumpProcessingAction(cmd.getOptionValue(CMD_OPTION_ACTION).toLowerCase());
    if (result == null) {
        return null;
    }

    for (Option option : cmd.getOptions()) {
        result.setOption(option.getLongOpt(), option.getValue());
    }

    checkDuplicateStdOutOutput(result);

    return result;
}

From source file:org.wildfly.security.tool.Command.java

/**
 * Alerts if any of the command line options used are duplicated
 * @param cmdLine the command line options used when invoking the command, after parsing
 *///from  www .  j  av  a 2 s .  c om
public void printDuplicatesWarning(CommandLine cmdLine) {
    List<Option> optionsList = new ArrayList<>(Arrays.asList(cmdLine.getOptions()));
    Set<Option> duplicatesSet = new HashSet<>();
    for (Option option : cmdLine.getOptions()) {
        if (Collections.frequency(optionsList, option) > 1) {
            duplicatesSet.add(option);
        }
    }

    for (Option option : duplicatesSet) {
        System.out.println(ElytronToolMessages.msg.duplicateOptionSpecified(option.getLongOpt()));
    }
}

From source file:org.wildfly.security.tool.Command.java

/**
 * Alerts if any of the command line options used are duplicated, excluding commands
 * that are allowed to have duplicates//from ww  w  . j  av  a2 s . c  o  m
 * @param cmdLine the command line options used when invoking the command, after parsing
 * @param duplicatesAllowed list of the commands line options that can be duplicated. For example:
 *                          <code>
 *                              List<String> allowedDuplicates = new ArrayList<String>()
 *                                  {{ add(PASSWORD_CREDENTIAL_VALUE_PARAM);
*                                  }};
 *                          </code>
 */
public void printDuplicatesWarning(CommandLine cmdLine, List<String> duplicatesAllowed) {
    if (duplicatesAllowed == null) {
        return;
    }

    List<Option> optionsList = new ArrayList<>(Arrays.asList(cmdLine.getOptions()));
    Set<Option> duplicatesSet = new HashSet<>();
    for (Option option : cmdLine.getOptions()) {
        if (Collections.frequency(optionsList, option) > 1
                && !duplicatesAllowed.contains(option.getLongOpt())) {
            duplicatesSet.add(option);
        }
    }

    for (Option option : duplicatesSet) {
        System.out.println(ElytronToolMessages.msg.duplicateOptionSpecified(option.getLongOpt()));
    }
}

From source file:partes.projection.TreeProjection.java

/**
 * The main method.//ww w. j a  v a2  s.  c  o m
 * 
 * @param args
 *            the arguments
 */
public static void main(String[] args) {
    String fileTreeOfInteraction = "";
    String[] services = new String[1];
    services[0] = "";

    Options options = new Options();
    HelpFormatter formatter = new HelpFormatter();
    options.addOption("t", "interactiontree", true, "specify interaction tree file");
    options.addOption("p", "participant", true, "specify participant to project");
    CommandLineParser parser = new PosixParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(options, args);
        if (cmd.getOptions().length == 0) {
            formatter.printHelp("TreeProjection", options, true);
            System.exit(0);
        }

        fileTreeOfInteraction = cmd.getOptionValue("t");
        services[0] = cmd.getOptionValue("p");

        if (fileTreeOfInteraction == null || services[0] == null) {
            formatter.printHelp("TreeProjection", options, true);
            System.exit(0);
        }

    } catch (ParseException e) {
        formatter.printHelp("TreeProjection", options, true);
        System.exit(0);
    }

    ParticipantInteractionTreeGenerator tp = new TreeProjection();
    TreeUtils tu = new TreeUtils(fileTreeOfInteraction);

    Vector<ProjectionInfo> piv = tp.makeProjection(tu.getTree(), services);

    for (ProjectionInfo pi : piv) {
        XStream xstream = new XStream();
        String xml = xstream.toXML(pi.getProjectionTree());
        WriteToFile.writeToANewFileInOutputDir("TestSuite" + File.separator,
                "projection-" + pi.getService() + ".xml", xml);
    }

}

From source file:partes.refactorRunner.InteractionTreeBuilder.java

/**
 * The main method.//from   w w  w  .  ja  va 2s . c o  m
 * 
 * @param args
 *            the arguments
 * @throws BPMNmalformedException 
 * @throws JAXBException 
 * @throws FileNotFoundException 
 */
public static void main(String[] args) throws BPMNmalformedException, FileNotFoundException, JAXBException {

    String modelDir = "";
    Options options = new Options();
    HelpFormatter formatter = new HelpFormatter();
    options.addOption("m", "modeldir", true, "specify model dir");
    CommandLineParser parser = new PosixParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(options, args);
        if (cmd.getOptions().length == 0) {
            formatter.printHelp("refactorRunner", options, true);
            System.exit(0);
        }

        // get model option value
        modelDir = cmd.getOptionValue("m");

        if (modelDir == null) {
            formatter.printHelp("refactorRunner", options, true);
            System.exit(0);
        }

    } catch (ParseException e) {
        formatter.printHelp("refactorRunner", options, true);
        System.exit(0);
    }

    ChoreographyInteractionTreeGenerator j = new InteractionTreeBuilder();
    HashMap<String, Tree> r = j.buildInteractionTrees(modelDir);
    XStream xstream = new XStream();
    String xml = xstream.toXML(r);
    WriteToFile.writeToANewFileInOutputDir("TestSuite" + File.separator, "treeofinteraction.xml", xml.trim());

}

From source file:partes.service.PartesMain.java

/**
 * the main to call by command line//from w ww  .j  ava 2 s.  co  m
 * @param args
 * <pre>
 * -d                for the debug
 * -p /../../xyz.bpmn  for the bpmn2 choreography
 * -y /../../xyz.yml   for the .yml file with references role-wsdl
 * 
 * For the structure of the .yml file, see {@link #run(String, boolean, LinkedHashMap)}
 * </pre>
 */
public static void main(String[] args) {
    instance = new PartesMain();

    // create Options object
    Options options = new Options();

    // create an HelFormatter
    HelpFormatter formatter = new HelpFormatter();

    // add options
    options.addOption("d", "debug", false, "build xml files for debug [optional]");
    options.addOption("p", "partes", true, "specify bpmn path [required]");
    options.addOption("y", "yaml", true, "specify yaml path with list of wsdl [required]");

    CommandLineParser parser = new PosixParser();
    CommandLine cmd;
    // ================= manual default specification ====================

    if (args.length == 0) {// if no argument is passed, default is taken (for testing purpose)
        formatter.printHelp("PartesMain", options, true);
        System.out.println("\n\nno argument is passed, default is taken (for testing purpose)");
        args = new String[3];
        //          args[0]="-p "+args[0];
        args[0] = "-p /Users/deLac/Desktop/partes/airport/choreography.bpmn";
        //          args[0]="-p https://dl.dropboxusercontent.com/u/13520648/wholeWp6.bpmn";
        // args[0]="-p /Users/deLac/Documents/eclipse_workspace/BPMN2WKG2XSB/src/main/java/partes/service/choreography_2.bpmn2";
        args[1] = "-y /Users/deLac/Desktop/partes/airport/participants.yml";
        args[2] = "-d";
    }
    // ===========================================================

    boolean dbg = false;
    String bpmnFile = "";
    String yamlFile = "";

    try {
        cmd = parser.parse(options, args);
        if (cmd.getOptions().length == 0) {
            // automatically generate the help statement and exit
            formatter.printHelp("PartesMain", options, true);
            System.exit(0);
        }

        // debug
        dbg = false;
        if (cmd.hasOption("d")) {
            dbg = true;
        }

        // bpmn
        if (cmd.getOptionValue("partes") == null) {
            formatter.printHelp("PartesMain", options, true);
            System.exit(0);
        } else {
            bpmnFile = cmd.getOptionValue("partes").trim();
        }

        //yml
        if (cmd.getOptionValue("y") == null) {
            formatter.printHelp("PartesMain", options, true);
            System.exit(0);
        } else {
            yamlFile = cmd.getOptionValue("y").trim();
        }

    } catch (ParseException e) {
        formatter.printHelp("PartesMain", options, true);
        System.exit(0);
    }
    try {
        instance.run_withYmlPath(bpmnFile, dbg, yamlFile, "DefaultChoreography");
    } catch (BPMNmalformedException e) {
        String error = "BPMN choreography should respect some rules to be applied to Partes \n ";
        instance.handleError(error, e);
    } catch (TestGenerationException e) {
        String error = "ERROR maybe there is an arror in the matching between role and service\n ";
        instance.handleError(error, e);
    } catch (JAXBException e) {
        String error = "ERROR converting BPMN elements in java JAXB elements\n";
        instance.handleError(error, e);
    } catch (FileNotFoundException e) {
        String error = "ERROR file not found";
        instance.handleError(error, e);
    } catch (Exception ex) {
        ex.printStackTrace();
        instance.handleError(ex.getMessage(), ex);
    }

}

From source file:partes.testbuilder.TestBuilder.java

/**
 * The main method./* w  ww.  ja v  a  2  s .  co m*/
 * 
 * @param args
 *            the arguments
 */
public static void main(String[] args) {
    String fileOfTree = "";
    String wsdlLocation = "";
    String portTypeToSearch = "";

    Options options = new Options();
    HelpFormatter formatter = new HelpFormatter();
    options.addOption("f", "projectionfile", true, "specify projection file");
    options.addOption("w", "wsdl", true, "specify wsdl of service");
    options.addOption("p", "porttype", true, "specify porttype to test");
    CommandLineParser parser = new PosixParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(options, args);
        if (cmd.getOptions().length == 0) {
            formatter.printHelp("TestBuilder", options, true);
            System.exit(0);
        }

        fileOfTree = cmd.getOptionValue("f");
        wsdlLocation = cmd.getOptionValue("w");
        portTypeToSearch = cmd.getOptionValue("p");

        if (fileOfTree == null || wsdlLocation == null || portTypeToSearch == null) {
            formatter.printHelp("TestBuilder", options, true);
            System.exit(0);
        }

    } catch (ParseException e) {
        formatter.printHelp("TestBuilder", options, true);
        System.exit(0);
    }

    ParticipantTestBuilder tb = new TestBuilder();
    TreeUtils tu = new TreeUtils(fileOfTree);

    try {
        String xmlTest = tb.makeSOAPuiProject(tu.getTree(), portTypeToSearch, wsdlLocation).getProjectDocument()
                .toString();

        WriteToFile.writeToANewFileInOutputDir("TestSuite" + File.separator,
                "test-" + portTypeToSearch + ".xml", xmlTest);
        System.exit(0);
    } catch (XmlException e) {
        //e.printStackTrace();
        System.out.println("TestBuilder causes an XmlException!");
    } catch (IOException e) {
        //e.printStackTrace();
        System.out.println("TestBuilder causes an IOException!");
    } catch (SoapUIException e) {
        //e.printStackTrace();
        System.out.println("TestBuilder causes an SoapUIException!");
    }
}

From source file:partes.utils.TreeToDot.java

/**
 * The main method./*from ww  w .  j a  v a  2s .  c  om*/
 * 
 * @param args
 *            the arguments
 */
public static void main(String[] args) {
    String fileTree = "";
    Options options = new Options();
    HelpFormatter formatter = new HelpFormatter();
    options.addOption("f", "filetree", true, "specify file of tree to visualize");
    CommandLineParser parser = new PosixParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(options, args);
        if (cmd.getOptions().length == 0) {
            formatter.printHelp("TreeToDot", options, true);
            System.exit(0);
        }

        // get model option value
        fileTree = cmd.getOptionValue("f");

        if (fileTree == null) {
            formatter.printHelp("TreeToDot", options, true);
            System.exit(0);
        }

    } catch (ParseException e) {
        formatter.printHelp("TreeToDot", options, true);
        System.exit(0);
    }

    TreeUtils tu = new TreeUtils(fileTree);

    if (fileTree.endsWith(".xml")) {
        fileTree = fileTree.substring(0, fileTree.length() - 4);
    }

    String imgName = fileTree + ".png";

    System.out.print("generating image... " + imgName);

    tu.generateImage(imgName);

    System.out.print(" done!");

}

From source file:pl.koziolekweb.Tod2Mpg.java

public static void main(String[] arguments) throws TodConversionException {
    CommandLineParser parser = new PosixParser();
    CommandLine commandLine;
    try {//from ww  w . jav  a 2  s .  co m
        commandLine = parser.parse(new TodConverterOptions(), arguments);
        ((TodConverterOption) (commandLine.getOptions()[0])).strategy().apply();

    } catch (ParseException e) {
        throw new TodConversionException(e);
    }
}

From source file:pt.ua.tm.neji.cli.Main.java

public static void main(String[] args) {
    //        installUncaughtExceptionHandler();

    int NUM_THREADS = Runtime.getRuntime().availableProcessors() - 1;
    NUM_THREADS = NUM_THREADS > 0 ? NUM_THREADS : 1;

    CommandLineParser parser = new GnuParser();
    Options options = new Options();
    options.addOption("h", "help", false, "Print this usage information.");

    options.addOption("i", "input", true, "Folder with corpus files.");
    options.addOption("o", "output", true, "Folder to save the annotated corpus files.");
    options.addOption("f", "input-filter", true, "Wildcard to filter files in input folder");

    options.addOption("p", "parser", true, "Folder that contains the parsing tool.");

    Option o = new Option("m", "models", true, "Folder that contains the ML models.");
    o.setArgs(Integer.MAX_VALUE);
    options.addOption(o);/*  w  ww.j a  v a2  s .co  m*/

    options.addOption("d", "dictionaires", true, "Folder that contains the dictionaries.");

    options.addOption("if", "input-format", true, "BIOC, RAW or XML");
    o = new Option("of", "output-formats", true, "A1, B64, BIOC, CONLL, JSON, NEJI or XML");
    o.setArgs(Integer.MAX_VALUE);
    options.addOption(o);

    options.addOption("ptool", "parsing-tool", true, "GDEP or OPENNLP (GDEP is set by default)");

    options.addOption("plang", "parsing-language", true,
            "DANISH, DUTCH, ENGLISH, FRENCH, GERMAN, PORTUGUESE or SWEDISH (ENGLISH is set by default)");

    options.addOption("plvl", "parsing-level", true,
            "TOKENIZATION, POS, LEMMATIZATION, CHUNKING or DEPENDENCY (TOKENIZATION is set by default)");

    options.addOption("pcls", "processor-class", true, "Full name of pipeline processor class.");

    options.addOption("custom", "custom-modules", true,
            "Names of custom modules to be used in order, separated by pipes. If a specified module are not a reader or a writer, it will be executed after dictionary and model processing.");

    options.addOption("x", "xml-tags", true, "XML tags to be considered, separated by commas.");

    options.addOption("v", "verbose", false, "Verbose mode.");
    options.addOption("s", "server", false, "Generate server.");
    options.addOption("c", "compressed", false, "If files are compressed using GZip.");
    options.addOption("noids", "include-no-ids", false, "If annotations without IDs should be included.");
    options.addOption("t", "threads", true,
            "Number of threads. By default, if more than one core is available, it is the number of cores minus 1.");

    options.addOption("fp", "false-positives-filter", true, "File that contains the false positive terms.");
    options.addOption("gn", "semantic-groups-normalization", true,
            "File that contains the semantic groups normalization terms.");

    CommandLine commandLine = null;
    try {
        // Parse the program arguments
        commandLine = parser.parse(options, args);
    } catch (ParseException ex) {
        logger.error("There was a problem processing the input arguments.", ex);
        return;
    }

    // Show help text
    if (commandLine.hasOption('h')) {
        printHelp(options, "");
        return;
    }

    // No options
    if (commandLine.getOptions().length == 0) {
        printHelp(options, "");
        return;
    }

    // Generate server from dictionary, model and parser parameters
    boolean generateServer = false;
    if (commandLine.hasOption('s')) {
        generateServer = true;
    }

    // Get corpus folder for input
    String folderCorpusIn = null;
    if (commandLine.hasOption('i')) {
        folderCorpusIn = commandLine.getOptionValue('i');
        File test = new File(folderCorpusIn);
        if (!test.isDirectory() || !test.canRead()) {
            logger.error("The specified path is not a folder or is not readable.");
            return;
        }
        folderCorpusIn = test.getAbsolutePath();
        folderCorpusIn += File.separator;
    } else {
        printHelp(options, "Please specify the input corpus folder.");
        return;
    }

    String inputFolderWildcard = null;
    if (commandLine.hasOption("f")) {
        inputFolderWildcard = commandLine.getOptionValue("f");
    }

    // Get Input format
    InputFormat inputFormat;
    if (commandLine.hasOption("if")) {
        inputFormat = InputFormat.valueOf(commandLine.getOptionValue("if"));
    } else {
        printHelp(options, "Please specify the input format.");
        return;
    }

    // Get corpus folder for output
    String folderCorpusOut = null;
    if (commandLine.hasOption('o')) {
        folderCorpusOut = commandLine.getOptionValue('o');
        File test = new File(folderCorpusOut);
        if (!test.isDirectory() || !test.canWrite()) {
            logger.error("The specified path is not a folder or is not writable.");
            return;
        }
        folderCorpusOut = test.getAbsolutePath();
        folderCorpusOut += File.separator;
    } else {
        printHelp(options, "Please specify the output corpus folder.");
        return;
    }

    // Get Output format
    List<OutputFormat> outputFormats = new ArrayList<>();
    if (commandLine.hasOption("of")) {
        String[] command = commandLine.getOptionValues("of");
        for (String s : command) {
            OutputFormat f = OutputFormat.valueOf(s);
            if (f.equals(OutputFormat.A1) || f.equals(OutputFormat.JSON) || f.equals(OutputFormat.NEJI)) {
                if (inputFormat.equals(InputFormat.XML)) {
                    logger.error("XML input format only supports XML and CoNLL output formats, "
                            + "since other formats are based on character positions.");
                    return;
                }
            }
            outputFormats.add(f);
        }
    } else {
        printHelp(options, "Please specify the output formats (in case of multiple formats, "
                + "separate them with a \"\\|\").");
        return;
    }

    // Get XML tags
    String[] xmlTags = null;
    if (inputFormat.equals(InputFormat.XML)) {
        if (commandLine.hasOption("x")) {
            xmlTags = commandLine.getOptionValue("x").split(",");
        } else {
            printHelp(options, "Please specify XML tags to be used.");
            return;
        }
    }

    // Get models folder
    String modelsFolder = null;
    if (commandLine.hasOption('m')) {
        modelsFolder = commandLine.getOptionValue('m');

        File test = new File(modelsFolder);
        if (!test.isDirectory() || !test.canRead()) {
            logger.error("The specified models path is not a folder or is not readable.");
            return;
        }
        modelsFolder = test.getAbsolutePath();
        modelsFolder += File.separator;
    }

    // Get dictionaries folder
    String dictionariesFolder = null;
    if (commandLine.hasOption('d')) {
        dictionariesFolder = commandLine.getOptionValue('d');

        File test = new File(dictionariesFolder);
        if (!test.isDirectory() || !test.canRead()) {
            logger.error("The specified dictionaries path is not a folder or is not readable.");
            return;
        }
        dictionariesFolder = test.getAbsolutePath();
        dictionariesFolder += File.separator;
    }

    // Get parser folder
    String parserFolder = null;
    if (commandLine.hasOption("p")) {
        parserFolder = commandLine.getOptionValue("p");

        File test = new File(parserFolder);
        if (!test.isDirectory() || !test.canRead()) {
            logger.error("The specified parser path is not a folder or is not readable.");
            return;
        }
        parserFolder = test.getAbsolutePath();
        parserFolder += File.separator;
    }

    // Get processing modules
    String modulesCommandLine = "";
    if (commandLine.hasOption("custom")) {
        modulesCommandLine = commandLine.getOptionValue("custom");
    }

    // Get verbose mode
    boolean verbose = commandLine.hasOption('v');
    Constants.verbose = verbose;

    if (Constants.verbose) {
        MalletLogger.getGlobal().setLevel(Level.INFO);
        // Redirect sout
        LoggingOutputStream los = new LoggingOutputStream(LoggerFactory.getLogger("stdout"), false);
        System.setOut(new PrintStream(los, true));

        // Redirect serr
        los = new LoggingOutputStream(LoggerFactory.getLogger("sterr"), true);
        System.setErr(new PrintStream(los, true));
    } else {
        MalletLogger.getGlobal().setLevel(Level.OFF);
    }

    // Redirect JUL to SLF4
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();

    // Get compressed mode
    boolean compressed = false;
    if (commandLine.hasOption('c')) {
        compressed = true;
    }

    // Get threads
    String threadsText = null;
    if (commandLine.hasOption('t')) {
        threadsText = commandLine.getOptionValue('t');
        NUM_THREADS = Integer.parseInt(threadsText);
        if (NUM_THREADS <= 0 || NUM_THREADS > 32) {
            logger.error("Illegal number of threads. Must be between 1 and 32.");
            return;
        }
    }

    // Load pipeline processor
    Class processor = FileProcessor.class;
    if (commandLine.hasOption("pcls")) {
        String processorName = commandLine.getOptionValue("pcls");
        try {
            processor = Class.forName(processorName);
        } catch (ClassNotFoundException ex) {
            logger.error("Could not load pipeline processor \"" + processorName + "\"");
            return;
        }
    }

    // Load parsing tool
    ParserTool parsingTool = ParserTool.GDEP;
    if (commandLine.hasOption("ptool")) {
        String parsingToolName = commandLine.getOptionValue("ptool");
        try {
            parsingTool = ParserTool.valueOf(parsingToolName);
        } catch (IllegalArgumentException ex) {
            logger.error("Invalid parsing tool \"" + parsingToolName + "\". " + "Must be one of "
                    + StringUtils.join(ParserTool.values(), ", "));
            return;
        }
    }

    // Load parsing language
    ParserLanguage parsingLanguage = ParserLanguage.ENGLISH;
    if (commandLine.hasOption("plang")) {
        String parsingLanguageName = commandLine.getOptionValue("plang");
        try {
            parsingLanguage = ParserLanguage.valueOf(parsingLanguageName);
        } catch (IllegalArgumentException ex) {
            logger.error("Invalid parsing language \"" + parsingLanguageName + "\". " + "Must be one of "
                    + StringUtils.join(ParserLanguage.values(), ", "));
            return;
        }
    }

    // Load parsing level
    ParserLevel parsingLevel = ParserLevel.TOKENIZATION;
    if (commandLine.hasOption("plvl")) {
        String parsingLevelName = commandLine.getOptionValue("plvl");
        try {
            parsingLevel = ParserLevel.valueOf(parsingLevelName);
        } catch (IllegalArgumentException ex) {
            logger.error("Invalid parsing level \"" + parsingLevelName + "\". " + "Must be one of "
                    + StringUtils.join(ParserLevel.values(), ", "));
            return;
        }
    } else {
        // Set model parsing level if ML will be used to annotate and no parsing level has been setted
        if (modelsFolder != null) {
            try {
                parsingLevel = getModelsParsingLevel(modelsFolder);
            } catch (NejiException ex) {
                logger.error("Could not load models parsing level.");
                return;
            }
        }
    }

    // Get if annotations without ids should be included
    boolean includeAnnotationsWithoutIDs = false;
    if (commandLine.hasOption("noids")) {
        includeAnnotationsWithoutIDs = true;
    }

    // Get false positives filter
    byte[] fpByteArray = null;
    if (commandLine.hasOption("fp")) {
        String fpPath = commandLine.getOptionValue("fp");

        File test = new File(fpPath);
        if (!test.isFile() || !test.canRead()) {
            logger.error("The specified false positives path is not a file or is not readable.");
            return;
        }

        fpPath = test.getAbsolutePath();
        fpPath += File.separator;
        try {
            fpByteArray = IOUtils.toByteArray(new FileInputStream(new File(fpPath)));
        } catch (IOException ex) {
            logger.error("There was a problem loading the false positives " + "file.", ex);
            return;
        }
    }

    // Get semantic groups normalization
    byte[] groupsNormByteArray = null;
    if (commandLine.hasOption("gn")) {
        String gnPath = commandLine.getOptionValue("gn");

        File test = new File(gnPath);
        if (!test.isFile() || !test.canRead()) {
            logger.error(
                    "The specified semantic groups normalization path " + "is not a file or is not readable.");
            return;
        }

        gnPath = test.getAbsolutePath();
        gnPath += File.separator;
        try {
            groupsNormByteArray = IOUtils.toByteArray(new FileInputStream(new File(gnPath)));
        } catch (IOException ex) {
            logger.error("There was a problem loading the semantic groups " + "normalization file.", ex);
            return;
        }
    }

    // Context is built through a descriptor first, so that the pipeline can be validated before any processing
    ContextConfiguration descriptor = null;
    try {
        descriptor = new ContextConfiguration.Builder().withInputFormat(inputFormat)
                .withOutputFormats(outputFormats).withParserTool(parsingTool)
                .withParserLanguage(parsingLanguage).withParserLevel(parsingLevel).parseCLI(modulesCommandLine)
                .build();

        descriptor.setFalsePositives(fpByteArray);
        descriptor.setSemanticGroupsNormalization(groupsNormByteArray);
    } catch (NejiException ex) {
        ex.printStackTrace();
        System.exit(1);
    }

    if (generateServer) {
        try {
            generateServer(descriptor, modelsFolder, dictionariesFolder, includeAnnotationsWithoutIDs);

        } catch (IOException ex) {
            ex.printStackTrace();
            System.exit(1);
        }
    } else {
        boolean storeDocuments = false;

        Context context = new Context(descriptor, modelsFolder, // Models
                dictionariesFolder, // Dictionaries folder
                parserFolder // Parser folder
        );

        try {
            BatchExecutor batchExecutor = new FileBatchExecutor(folderCorpusIn, folderCorpusOut, compressed,
                    NUM_THREADS, inputFolderWildcard, storeDocuments, includeAnnotationsWithoutIDs);

            if (xmlTags == null) {
                batchExecutor.run(processor, context);
            } else {
                batchExecutor.run(processor, context, new Object[] { xmlTags });
            }

        } catch (Exception ex) {
            logger.error("There was a problem running the batch.", ex);
        }
    }
}