Search in sources :

Example 1 with XTemporal

use of org.opensextant.extractors.xtemporal.XTemporal in project Xponents by OpenSextant.

the class DateNormalizationTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    try {
        timeFinder = new XTemporal(true);
        timeFinder.configure();
    } catch (Exception err) {
        err.printStackTrace();
    }
}
Also used : XTemporal(org.opensextant.extractors.xtemporal.XTemporal) BeforeClass(org.junit.BeforeClass)

Example 2 with XTemporal

use of org.opensextant.extractors.xtemporal.XTemporal in project Xponents by OpenSextant.

the class TestXTemporal method main.

/**
     * 
     * @param args
     */
public static void main(String[] args) {
    boolean debug = true;
    // default test patterns, run test/debug mode.
    xdt = new XTemporal(debug);
    boolean systemTest = false;
    boolean adhocTest = false;
    try {
        gnu.getopt.Getopt opts = new gnu.getopt.Getopt("XTemporal", args, "fa");
        int c;
        while ((c = opts.getopt()) != -1) {
            switch(c) {
                case 'f':
                    systemTest = true;
                    break;
                case 'a':
                    adhocTest = true;
                    break;
                default:
                    usage();
                    System.exit(1);
            }
        }
    } catch (Exception err) {
        usage();
        System.exit(1);
    }
    try {
        TestXTemporal test = new TestXTemporal();
        xdt.configure();
        if (systemTest) {
            System.out.println("\tSYSTEM TESTS=======\n");
            test.systemTests();
        }
        if (adhocTest) {
            System.out.println("\tADHOC TESTS=======\n");
            test.adhocTests();
        }
    } catch (ConfigException exErr) {
        exErr.printStackTrace();
    }
}
Also used : XTemporal(org.opensextant.extractors.xtemporal.XTemporal) ConfigException(org.opensextant.ConfigException) ConfigException(org.opensextant.ConfigException)

Example 3 with XTemporal

use of org.opensextant.extractors.xtemporal.XTemporal in project Xponents by OpenSextant.

the class BasicGeoTemporalProcessing method setup.

/**   Ideally you should separate your one-time initialization steps, configuring your extractors
     * apart from the repetitive steps of setting up Jobs and Inputs.   Outputs you might setup once
     * for the entire JVM session, or it may be something you do periodically.  In summary:
     *
     * configure separately:
     *   a) extractors, converters
     *   b) job inputs and parameters
     *   c) output formatters
     *   d) other resources, e.g., filters
     */
public void setup(String inFile, List<String> outFormats, String outFile, String tempDir) throws ConfigException, ProcessingException, IOException {
    params.isdefault = false;
    if (!validateParameters(inFile, outFormats, outFile, tempDir, params)) {
        throw new ProcessingException("VALIDATION ERRORS: " + runnerMessage.toString());
    }
    // If you are dead-sure you want only coordinates from text, then just use XCoord.
    // Otherwise SimpleGeocoder does both coords + names.
    // 
    //XCoord xcoord = new XCoord();
    //xcoord.configure();
    //this.addExtractor(xcoord);
    // Testing only
    params.tag_places = true;
    params.tag_coordinates = true;
    params.output_countries = false;
    PlaceGeocoder geocoder = new PlaceGeocoder();
    geocoder.enablePersonNameMatching(true);
    geocoder.setParameters(params);
    geocoder.configure();
    this.addExtractor(geocoder);
    XTemporal xtemp = new XTemporal();
    xtemp.configure();
    this.addExtractor(xtemp);
    converter = new XText();
    converter.enableHTMLScrubber(false);
    converter.enableSaving(true);
    converter.enableOverwrite(false);
    converter.setConversionListener(this);
    // 
    if (tempDir != null) {
        converter.getPathManager().setConversionCache(tempDir);
    } else {
        converter.enableSaving(false);
    }
    try {
        converter.setup();
    } catch (IOException ioerr) {
        throw new ConfigException("Document converter could not start", ioerr);
    }
    this.params.inputFile = inFile.trim();
    this.params.outputFile = outFile.trim();
    if (outFormats != null) {
        for (String fmt : outFormats) {
            params.addOutputFormat(fmt);
            AbstractFormatter formatter = createFormatter(fmt, params);
            formatter.overwrite = overwriteOutput;
            this.addFormatter(formatter);
            //if (formatter instanceof CSVFormatter) {
            //    formatter.addField(OpenSextantSchema.FILEPATH.getName());
            //    formatter.addField(OpenSextantSchema.MATCH_TEXT.getName());
            // }
            formatter.start(params.getJobName());
        }
    }
}
Also used : PlaceGeocoder(org.opensextant.extractors.geo.PlaceGeocoder) XTemporal(org.opensextant.extractors.xtemporal.XTemporal) XText(org.opensextant.xtext.XText) ConfigException(org.opensextant.ConfigException) IOException(java.io.IOException) AbstractFormatter(org.opensextant.output.AbstractFormatter) ProcessingException(org.opensextant.processing.ProcessingException)

Aggregations

XTemporal (org.opensextant.extractors.xtemporal.XTemporal)3 ConfigException (org.opensextant.ConfigException)2 IOException (java.io.IOException)1 BeforeClass (org.junit.BeforeClass)1 PlaceGeocoder (org.opensextant.extractors.geo.PlaceGeocoder)1 AbstractFormatter (org.opensextant.output.AbstractFormatter)1 ProcessingException (org.opensextant.processing.ProcessingException)1 XText (org.opensextant.xtext.XText)1