Search in sources :

Example 6 with ConfigException

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);
    }
}
Also used : PlaceGeocoder(org.opensextant.extractors.geo.PlaceGeocoder) MatchFilter(org.opensextant.extraction.MatchFilter) ConfigException(org.opensextant.ConfigException) IOException(java.io.IOException) URL(java.net.URL)

Example 7 with ConfigException

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();
    }
}
Also used : XTemporal(org.opensextant.extractors.xtemporal.XTemporal) ConfigException(org.opensextant.ConfigException) ConfigException(org.opensextant.ConfigException)

Example 8 with ConfigException

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;
}
Also used : ConfigException(org.opensextant.ConfigException) File(java.io.File)

Example 9 with ConfigException

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;
        }
    }
}
Also used : ConfigException(org.opensextant.ConfigException) TextMatch(org.opensextant.extraction.TextMatch) Geocoding(org.opensextant.data.Geocoding) Feature(org.opensextant.giscore.events.Feature)

Example 10 with ConfigException

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);
    }
}
Also used : ConfigException(org.opensextant.ConfigException) TextInput(org.opensextant.data.TextInput) SolrServerException(org.apache.solr.client.solrj.SolrServerException) ExtractionException(org.opensextant.extraction.ExtractionException) ConfigException(org.opensextant.ConfigException) IOException(java.io.IOException)

Aggregations

ConfigException (org.opensextant.ConfigException)28 IOException (java.io.IOException)20 File (java.io.File)5 URL (java.net.URL)4 MimeTypeParseException (javax.activation.MimeTypeParseException)3 MessagingException (javax.mail.MessagingException)3 SolrServerException (org.apache.solr.client.solrj.SolrServerException)3 PlaceGeocoder (org.opensextant.extractors.geo.PlaceGeocoder)3 XText (org.opensextant.xtext.XText)3 PSTFile (com.pff.PSTFile)2 MalformedURLException (java.net.MalformedURLException)2 HashSet (java.util.HashSet)2 TextMatch (org.opensextant.extraction.TextMatch)2 PersonNameFilter (org.opensextant.extractors.geo.rules.PersonNameFilter)2 TaxonMatcher (org.opensextant.extractors.xtax.TaxonMatcher)2 XTemporal (org.opensextant.extractors.xtemporal.XTemporal)2 PSTException (com.pff.PSTException)1 LongOpt (gnu.getopt.LongOpt)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1