Search in sources :

Example 1 with DateMatch

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

the class DateNormalizationTest method ensureTimeZone.

/**
     * Note that this may report false negatives if the JVM's default time
     * zone is UTC.
     */
@Test
public void ensureTimeZone() {
    // Not parseable by default.  pattern is too noisy.
    final TextMatchResult result1 = timeFinder.extract_dates("Oct 07", "dummy");
    System.err.println("1 " + result1.matches.toString());
    assertEquals(0, result1.matches.size());
    final TextMatchResult result2 = timeFinder.extract_dates("Oct 2007", "dummy");
    System.err.println("2 " + result1.matches.toString());
    assertEquals(1, result2.matches.size());
    DateMatch dt = (DateMatch) result2.matches.get(0);
    long noon = (12 * 3600 * 1000);
    assertEquals(1191196800000L + noon, dt.datenorm.getTime());
}
Also used : DateMatch(org.opensextant.extractors.xtemporal.DateMatch) TextMatchResult(org.opensextant.extractors.flexpat.TextMatchResult) Test(org.junit.Test)

Example 2 with DateMatch

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

the class TestXTemporalReporter method save_result.

/**
     * @param results
     * @throws IOException
     */
public void save_result(TextMatchResult results) throws IOException {
    Map<String, Object> row = null;
    if (!results.matches.isEmpty()) {
        for (TextMatch tm : results.matches) {
            row = new HashMap<String, Object>();
            row.put(header[0], results.result_id);
            row.put(header[1], "PASS");
            DateMatch m = (DateMatch) tm;
            String msg = results.message;
            if (m.is_submatch) {
                msg += "; Is Submatch";
            }
            row.put(header[2], msg);
            row.put(header[3], m.pattern_id);
            row.put(header[4], m.getText());
            row.put(header[5], m.datenorm.toString());
            row.put(header[6], m.datenorm_text);
            row.put(header[7], m.resolution.toString());
            row.put(header[8], m.datenorm.getTime());
            row.put(header[9], m.start);
            report.write(row, header, xtempResultsSpec);
        }
    } else {
        row = new HashMap<String, Object>();
        row.put(header[0], results.result_id);
        row.put(header[1], "FAIL");
        row.put(header[2], results.get_trace());
        report.write(row, header, xtempResultsSpec);
    }
}
Also used : DateMatch(org.opensextant.extractors.xtemporal.DateMatch) TextMatch(org.opensextant.extraction.TextMatch)

Aggregations

DateMatch (org.opensextant.extractors.xtemporal.DateMatch)2 Test (org.junit.Test)1 TextMatch (org.opensextant.extraction.TextMatch)1 TextMatchResult (org.opensextant.extractors.flexpat.TextMatchResult)1