use of org.opensextant.ConfigException in project Xponents by OpenSextant.
the class XlayerRestlet method configure.
/**
*
* @throws ConfigException
*/
public void configure() throws ConfigException {
// Default - process place/country mentions in document texts.
//
tagger = new PlaceGeocoder();
// tagger.setParameters(this.params); See Xponents concept of Parameters
tagger.enablePersonNameMatching(true);
tagger.configure();
// TODO: refine this filter list. Use "/filters/non-placenames,user.csv" going forward.
//
String userFilterPath = "/filters/non-placenames,user.csv";
URL filterFile = getClass().getResource(userFilterPath);
if (filterFile != null) {
//
try {
MatchFilter filt = new MatchFilter(filterFile);
tagger.setMatchFilter(filt);
} catch (IOException err) {
throw new ConfigException("Setup error with geonames utility or other configuration", err);
}
} else {
info("Optional user filter not found. User exclusion list is file=" + userFilterPath);
}
}
use of org.opensextant.ConfigException 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.ConfigException in project Xponents by OpenSextant.
the class PathManager method getArchiveExportDir.
public File getArchiveExportDir(File input) throws ConfigException, IOException {
String aName = FilenameUtils.getBaseName(input.getName());
String aExt = FilenameUtils.getExtension(input.getName());
String outputName = String.format("%s_%s", aName, aExt.toLowerCase());
// Set output name to input name. That is, once we extract A.zip to ./(originals)/A_zip/ this de-archived folder will
// Also exist in ./(converted)/A_zip/ or ./(originals)/A_zip/xtext/ embedded.
//
//setOutputNode(inputNode);
String saveTo = null;
// unpack, traverse, convert, save
if (extractedChildrenCache != null) {
// Save converted items in a parallel archive for this zip archive.
saveTo = PathManager.createPath(extractedChildrenCache, outputName);
} else if (this.saveExtractedChildrenWithOriginals) {
saveTo = PathManager.createPath(input.getParentFile().getAbsolutePath(), outputName);
} else {
throw new ConfigException("Archive Files cannot be dearchived without a target folder to store child binaries");
}
File saveFolder = new File(saveTo);
if (!saveFolder.exists()) {
FileUtility.makeDirectory(saveFolder);
}
log.debug("ARCHIVE FILE={}, node-in={}, cache-in={}, export={}", input, outputName, outputNode, saveFolder);
return saveFolder;
}
use of org.opensextant.ConfigException in project Xponents by OpenSextant.
the class GISDataFormatter method writeGeocodingResult.
/**
* Implementation of adding info extraction/geocoding restults to GIS outputs.
*/
@Override
public void writeGeocodingResult(ExtractionResult rowdata) {
boolean error = false;
log.debug("Adding data for File {} Count={}", rowdata.recordFile, rowdata.matches.size());
for (TextMatch g : rowdata.matches) {
if (filterOut(g)) {
continue;
}
// Increment ID
id++;
// Only TextMatches that implement the Geocoding interface are
// allowed here:
Geocoding geocoding = getGeocoding(g);
if (geocoding == null) {
log.debug("Non-geo will be ignored: {}", g);
continue;
}
log.debug("Add {}#{}", id, g);
try {
for (Feature row : gisDataModel.buildRows(id, geocoding, g, rowdata.attributes, rowdata)) {
log.debug("FEATURE: {}", row);
this.os.write(row);
}
} catch (ConfigException fieldErr) {
if (!error) {
log.error("OUTPUTTER, ERR=" + fieldErr);
}
error = true;
}
}
}
use of org.opensextant.ConfigException in project Xponents by OpenSextant.
the class TaxonMatcher method configure.
@Override
public void configure() throws ConfigException {
try {
initialize();
extract(new TextInput("__initialization___", "trivial priming of the solr pump"));
} catch (Exception err) {
throw new ConfigException("Failed to configure TaxMatcher", err);
}
}
Aggregations