aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/main/java/com/yahoo/searchlib/gbdt/GbdtConverter.java
blob: 77fb2e8aba6b8f4415b26e54f3895cc17c017642 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchlib.gbdt;

import com.yahoo.yolean.Exceptions;

import java.io.FileNotFoundException;

/**
 * @author Simon Thoresen Hult
 */
public class GbdtConverter {

    /**
     * Implements an application main function so that the converter can be used as a command-line tool.
     *
     * @param args List of arguments.
     */
    public static void main(String[] args) {
        if (args.length != 1) {
            System.err.println("Usage: GbdtConverter <filename>");
            System.exit(1);
        }
        try {
            System.out.println(GbdtModel.fromXmlFile(args[0]).toRankingExpression());
        } catch (FileNotFoundException e) {
            System.err.println("Could not find file '" + args[0] + "'.");
            System.exit(1);
        } catch (Exception e) {
            System.err.println("An error occurred while parsing the content of file '" + args[0] + "': " +
                               Exceptions.toMessageString(e));
            System.exit(1);
        }
    }
}