Search in sources :

Example 1 with PatternsOfLife

use of org.opensextant.extractors.poli.PatternsOfLife in project Xponents by OpenSextant.

the class TestPoLi method main.

/**
     * Run a simple test.
     * 
     * @param args
     *            only one argument accepted: a text file input.
     */
public static void main(String[] args) {
    boolean debug = true;
    boolean systemTest = false;
    String testFile = null;
    String config = null;
    try {
        gnu.getopt.Getopt opts = new gnu.getopt.Getopt("Poli", args, "c:u:f");
        int c;
        while ((c = opts.getopt()) != -1) {
            switch(c) {
                case 'f':
                    System.out.println("\tSystem TESTS======= ");
                    systemTest = true;
                    break;
                case 'u':
                    testFile = opts.getOptarg();
                    System.out.println("\tUser TESTS======= FILE=" + testFile);
                    break;
                case 'c':
                    config = opts.getOptarg();
                    System.out.println("\tUser Patterns Configuration ======= FILE=" + config);
                    break;
                default:
                    TestPoLi.usage();
                    System.exit(1);
            }
        }
    } catch (Exception runErr) {
        runErr.printStackTrace();
        TestPoLi.usage();
        System.exit(1);
    }
    PatternsOfLife poli = null;
    try {
        // Use default config file.
        poli = new PatternsOfLife(debug);
        if (config == null) {
            // default
            poli.configure();
        } else {
            poli.configure(config);
        }
    } catch (ConfigException xerr) {
        xerr.printStackTrace();
        System.exit(-1);
    }
    try {
        TestPoLiReporter test = new TestPoLiReporter(poli);
        if (systemTest) {
            test.test();
        } else if (testFile != null) {
            test.testUserFile(testFile);
        }
    } catch (NormalizationException xerr) {
        xerr.printStackTrace();
    } catch (IOException ioerr) {
        ioerr.printStackTrace();
    }
}
Also used : ConfigException(org.opensextant.ConfigException) IOException(java.io.IOException) ConfigException(org.opensextant.ConfigException) NormalizationException(org.opensextant.extraction.NormalizationException) IOException(java.io.IOException) NormalizationException(org.opensextant.extraction.NormalizationException) PatternsOfLife(org.opensextant.extractors.poli.PatternsOfLife)

Aggregations

IOException (java.io.IOException)1 ConfigException (org.opensextant.ConfigException)1 NormalizationException (org.opensextant.extraction.NormalizationException)1 PatternsOfLife (org.opensextant.extractors.poli.PatternsOfLife)1