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();
}
}
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();
}
}
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());
}
}
}
Aggregations