Search in sources :

Example 1 with RegexPatternManager

use of org.opensextant.extractors.flexpat.RegexPatternManager in project Xponents by OpenSextant.

the class TestXCoord method systemTests.

/**
     * Using the TestUtility, all patterns are tested and reported to the
     * results folder.
     */
public void systemTests() {
    RegexPatternManager mgr = xcoord.getPatternManager();
    log.info("\n\n=== SYSTEM TESTS ===\n\n");
    if (!mgr.testing) {
        log.info("TESTING OFF -- TURN ON DEBUG in LOG4J");
        return;
    }
    xcoord.match_UTM(true);
    xcoord.match_MGRS(true);
    xcoord.match_DD(true);
    xcoord.match_DMS(true);
    xcoord.match_DM(true);
    try {
        TestXCoordReporter tester = new TestXCoordReporter("./results/xcoord_System.csv");
        for (PatternTestCase tst : mgr.testcases) {
            TextMatchResult results = xcoord.extract_coordinates(tst.text, tst.id, tst.family_id);
            results.add_trace("Test Payload: " + tst.text);
            if (!results.evaluated) {
                continue;
            }
            log.info("=========SYSTEM TEST " + tst.id + " FOUND:" + (results.matches.isEmpty() ? "NOTHING" : results.matches.size()));
            tester.save_result(null, results);
        }
        tester.close_report();
    } catch (Exception err) {
        log.error("Not finishing tests", err);
        return;
    }
    log.info("=== SYSTEM TESTS DONE ===");
}
Also used : PatternTestCase(org.opensextant.extractors.flexpat.PatternTestCase) TextMatchResult(org.opensextant.extractors.flexpat.TextMatchResult) RegexPatternManager(org.opensextant.extractors.flexpat.RegexPatternManager) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with RegexPatternManager

use of org.opensextant.extractors.flexpat.RegexPatternManager in project Xponents by OpenSextant.

the class XTemporal method createPatternManager.

@Override
protected RegexPatternManager createPatternManager(InputStream strm, String name) throws IOException {
    patterns_file = name;
    PatternManager mgr = new PatternManager(strm, patterns_file);
    mgr.testing = debug;
    return mgr;
}
Also used : RegexPatternManager(org.opensextant.extractors.flexpat.RegexPatternManager)

Aggregations

RegexPatternManager (org.opensextant.extractors.flexpat.RegexPatternManager)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 PatternTestCase (org.opensextant.extractors.flexpat.PatternTestCase)1 TextMatchResult (org.opensextant.extractors.flexpat.TextMatchResult)1