Elasticsearch() { super("starts elasticsearch", () -> {}); // we configure logging later so we override the base class from configuring logging versionOption = parser.acceptsAll(Arrays.asList("V", "version"), "Prints elasticsearch version information and exits"); daemonizeOption = parser.acceptsAll(Arrays.asList("d", "daemonize"), "Starts Elasticsearch in the background") .availableUnless(versionOption); pidfileOption = parser.acceptsAll(Arrays.asList("p", "pidfile"), "Creates a pid file in the specified path on start") .availableUnless(versionOption) .withRequiredArg() .withValuesConvertedBy(new PathConverter()); quietOption = parser.acceptsAll(Arrays.asList("q", "quiet"), "Turns off standard output/error streams logging in console") .availableUnless(versionOption) .availableUnless(daemonizeOption); }
/** * Mandates mutual exclusiveness for the options built by the specified builders. * * @param specs descriptors for options that should be mutually exclusive on a command line. * @throws NullPointerException if {@code specs} is {@code null} */ public void mutuallyExclusive( OptionSpecBuilder... specs ) { for ( int i = 0; i < specs.length; i++ ) { for ( int j = 0; j < specs.length; j++ ) { if ( i != j ) specs[i].availableUnless( specs[j] ); } } }
/** * Mandates mutual exclusiveness for the options built by the specified builders. * * @param specs descriptors for options that should be mutually exclusive on a command line. * @throws NullPointerException if {@code specs} is {@code null} */ public void mutuallyExclusive( OptionSpecBuilder... specs ) { for ( int i = 0; i < specs.length; i++ ) { for ( int j = 0; j < specs.length; j++ ) { if ( i != j ) specs[i].availableUnless( specs[j] ); } } }
Elasticsearch() { super("starts elasticsearch"); versionOption = parser.acceptsAll(Arrays.asList("V", "version"), "Prints elasticsearch version information and exits"); daemonizeOption = parser.acceptsAll(Arrays.asList("d", "daemonize"), "Starts Elasticsearch in the background") .availableUnless(versionOption); pidfileOption = parser.acceptsAll(Arrays.asList("p", "pidfile"), "Creates a pid file in the specified path on start") .availableUnless(versionOption) .withRequiredArg() .withValuesConvertedBy(new PathConverter()); quietOption = parser.acceptsAll(Arrays.asList("q", "quiet"), "Turns off standard ouput/error streams logging in console") .availableUnless(versionOption) .availableUnless(daemonizeOption); }
Elasticsearch() { super("starts elasticsearch", () -> {}); // we configure logging later so we override the base class from configuring logging versionOption = parser.acceptsAll(Arrays.asList("V", "version"), "Prints elasticsearch version information and exits"); daemonizeOption = parser.acceptsAll(Arrays.asList("d", "daemonize"), "Starts Elasticsearch in the background") .availableUnless(versionOption); pidfileOption = parser.acceptsAll(Arrays.asList("p", "pidfile"), "Creates a pid file in the specified path on start") .availableUnless(versionOption) .withRequiredArg() .withValuesConvertedBy(new PathConverter()); quietOption = parser.acceptsAll(Arrays.asList("q", "quiet"), "Turns off standard output/error streams logging in console") .availableUnless(versionOption) .availableUnless(daemonizeOption); }
Elasticsearch() { super("starts elasticsearch", () -> {}); // we configure logging later so we override the base class from configuring logging versionOption = parser.acceptsAll(Arrays.asList("V", "version"), "Prints elasticsearch version information and exits"); daemonizeOption = parser.acceptsAll(Arrays.asList("d", "daemonize"), "Starts Elasticsearch in the background") .availableUnless(versionOption); pidfileOption = parser.acceptsAll(Arrays.asList("p", "pidfile"), "Creates a pid file in the specified path on start") .availableUnless(versionOption) .withRequiredArg() .withValuesConvertedBy(new PathConverter()); quietOption = parser.acceptsAll(Arrays.asList("q", "quiet"), "Turns off standard output/error streams logging in console") .availableUnless(versionOption) .availableUnless(daemonizeOption); }
public static void main(String[] args) throws IOException, SentenceAnnotatorLoadException, TalismaneException, ReflectiveOperationException { OptionParser parser = new OptionParser(); parser.accepts("serializeDiacriticizer", "serialize diacriticizer from lexicon"); parser.accepts("testDiacriticizer", "test serialized diacriticizer").availableUnless("serializeDiacriticizer"); parser.acceptsAll(Arrays.asList("?", "help"), "show help").availableUnless("serializeDiacriticizer", "testDiacriticizer").forHelp();
public static void main(String[] args) throws IOException, SentenceAnnotatorLoadException, TalismaneException, ReflectiveOperationException { OptionParser parser = new OptionParser(); parser.accepts("testLexicon", "test lexicon"); parser.acceptsAll(Arrays.asList("?", "help"), "show help").availableUnless("testLexicon").forHelp();
parser.accepts("train", "train model").availableUnless("analyse"); parser.accepts("evaluate", "evaluate annotated corpus").availableUnless("analyse", "train"); parser.accepts("compare", "compare two annotated corpora").availableUnless("analyse", "train", "evaluate"); parser.accepts("process", "process annotated corpus").availableUnless("analyse", "train", "evaluate", "compare"); parser.acceptsAll(Arrays.asList("?", "help"), "show help").availableUnless("analyse", "train", "evaluate", "compare", "process").forHelp(); OptionSpec<File> inputPatternFileOption = parser.accepts("inputPatternFile", "input pattern file").availableUnless(inputPatternOption).withRequiredArg() .ofType(File.class); OptionSpec<String> evalPatternOption = parser.accepts("evalPattern", "input pattern for evaluation").availableIf("evaluate", "compare").withRequiredArg() .ofType(String.class); OptionSpec<File> evalPatternFileOption = parser.accepts("evalPatternFile", "input pattern file for evaluation").availableUnless(evalPatternOption) .withRequiredArg().ofType(File.class); .accepts("builtInTemplate", "pre-defined output template: " + Arrays.toString(BuiltInTemplate.values())).availableUnless("train").withRequiredArg() .ofType(BuiltInTemplate.class); OptionSpec<File> templateOption = parser.accepts("template", "user-defined template for output").availableUnless("train", "builtInTemplate") .withRequiredArg().ofType(File.class);
public static void main(String[] args) throws IOException, SentenceAnnotatorLoadException, TalismaneException, ReflectiveOperationException { OptionParser parser = new OptionParser(); parser.accepts("serializeLexicon", "serialize lexicon"); parser.acceptsAll(Arrays.asList("?", "help"), "show help").availableUnless("serializeLexicon").forHelp(); OptionSpec<String> sessionIdOption = parser.accepts("sessionId", "the current session id - configuration read as talismane.core.[sessionId]") .requiredUnless("?", "help").withRequiredArg().ofType(String.class); OptionSpec<File> lexiconPropsFileOption = parser.accepts("lexiconProps", "the lexicon properties file").withRequiredArg().required().ofType(File.class); OptionSpec<File> outFileOption = parser.accepts("outFile", "where to write the lexicon").withRequiredArg().required().ofType(File.class); if (args.length <= 1) { parser.printHelpOn(System.out); return; } OptionSet options = parser.parse(args); File lexiconPropsFile = options.valueOf(lexiconPropsFileOption); File outFile = options.valueOf(outFileOption); Config config = ConfigFactory.load(); String sessionId = options.valueOf(sessionIdOption); TalismaneSession session = new TalismaneSession(config, sessionId); LexiconReader lexiconSerializer = new LexiconReader(session); List<PosTaggerLexicon> lexicons = lexiconSerializer.readLexicons(lexiconPropsFile); lexiconSerializer.serializeLexicons(lexicons, outFile); }