aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient-java/src/main/java/com/yahoo/vespasignificance/Main.java
blob: e368eebefa5b79855f310b7a694df28c6fc4bda9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

package com.yahoo.vespasignificance;

import java.io.IOException;
import java.util.List;

/**
 * The vespa-significance tool generates significance models based on input feed files.
 *
 * @author MariusArhaug
 */

public class Main {

    public static void main(String[] args) {
        try {
            if (args.length == 0) {
                System.err.println("No arguments provided. Use --help to see available options.");
                System.exit(1);
            }

            if (!args[0].equals("generate")) {
                System.err.println("Invalid command. Use 'generate' to generate significance models.");
                System.exit(1);
            }
            String[] commandLineArgs = List.of(args).subList(1, args.length).toArray(new String[0]);

            CommandLineOptions options = new CommandLineOptions();
            ClientParameters params = options.parseCommandLineArguments(commandLineArgs);

            if (params.help) {
                options.printHelp();
            } else {
                System.setProperty("vespa.replace_invalid_unicode", "true");
                SignificanceModelGenerator significanceModelGenerator = createSignificanceModelGenerator(params);

                significanceModelGenerator.generate();
            }
        } catch (IllegalArgumentException e) {
            System.err.printf("Failed to parse command line arguments: %s.\n", e.getMessage());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static SignificanceModelGenerator createSignificanceModelGenerator(ClientParameters params) {
        return new SignificanceModelGenerator(params);
    }
}