jcas.setDocumentText(metaText.toString() + sb.toString()); ae.process(jcas); Collection<IdentifiedAnnotation> collection = JCasUtil.select(jcas, IdentifiedAnnotation.class); Iterator<IdentifiedAnnotation> iterator = collection.iterator(); while (iterator.hasNext()) {
@Test public void testMidword() throws Exception { jCas.setDocumentText("HelloWorld"); processJCas(MONGO, erd, COLLECTION, MONGO_COLL, TYPE, LOCATION); assertEquals(0, JCasUtil.select(jCas, Location.class).size()); }
@Test public void testCaseSensitive() throws Exception { jCas.setDocumentText(PREFIX + "JamaICA"); processJCas(COUNTRY, erd, Country.PARAM_CASE_SENSITIVE, true); assertEquals(0, JCasUtil.select(jCas, Location.class).size()); }
@Test public void testMidword() throws Exception { jCas.setDocumentText("Desiring chocolate is not a sin"); processJCas(MONGO, erd, COLLECTION, MONGO_COLL, TYPE, BUZZWORD); assertEquals(0, JCasUtil.select(jCas, Buzzword.class).size()); }
@Test public void test2() throws Exception { jCas.setDocumentText("Derek is from Afghanistan"); ae.process(jCas); assertEquals(0, JCasUtil.select(jCas, Nationality.class).size()); }
@Test public void testBad() throws Exception { jCas.setDocumentText("This test was written at 301137Z FEB 13"); processJCas(); assertEquals(0, JCasUtil.select(jCas, Temporal.class).size()); jCas.reset(); jCas.setDocumentText("This test was written at 901137Z FEB 13"); processJCas(); assertEquals(0, JCasUtil.select(jCas, Temporal.class).size()); } }
@Test public void test() throws Exception { jCas.setDocumentText( "The second CVE to be issued, cve-1999-0002, describes a buffer overflow in NFS mountd."); processJCas(); assertEquals(1, JCasUtil.select(jCas, Vulnerability.class).size()); Vulnerability bw = JCasUtil.selectByIndex(jCas, Vulnerability.class, 0); assertEquals("cve-1999-0002", bw.getCoveredText()); } }
@Test public void testBadDayMonthYears() throws Exception { jCas.setDocumentText("She worked from 1st - 30th February 2015"); processJCas(); assertEquals( 1, JCasUtil.select(jCas, Temporal.class) .size()); // Month will be extracted, but the invalid date won't be Temporal t = JCasUtil.selectByIndex(jCas, Temporal.class, 0); assertEquals("February 2015", t.getCoveredText()); }
@Test public void testAllCapitals() throws Exception { AnalysisEngine ae = AnalysisEngineFactory.createEngine(TestAnnotator.class); jCas.setDocumentText("PERSON JOHN SMITH WAS SEEN ENTERING THE WAREHOUSE"); ae.process(jCas); assertEquals(0, JCasUtil.select(jCas, Person.class).size()); }
@Test public void testProperHeadMatchSameLocation() throws AnalysisEngineProcessException, ResourceInitializationException { String text = "We visited the south of Amercia and travelled to the deep south of America."; jCas.setDocumentText(text); processJCas(); processJCasWithSieve(8); List<ReferenceTarget> targets = new ArrayList<>(JCasUtil.select(jCas, ReferenceTarget.class)); assertEquals(1, targets.size()); }
@Test public void testProperHeadMatchDifferentLocations() throws AnalysisEngineProcessException, ResourceInitializationException { String text = "We visited the south of Amercia and went to the north of America."; jCas.setDocumentText(text); processJCas(); processJCasWithSieve(8); List<ReferenceTarget> targets = new ArrayList<>(JCasUtil.select(jCas, ReferenceTarget.class)); assertEquals(0, targets.size()); }
@Test public void testDropLeadingZeroes() throws Exception { jCas.setDocumentText( "Here's an IPv6 address with leading zeroes dropped: fe80:0:0:0:204:61ff:fe9d:f156."); processJCas(); assertEquals(1, JCasUtil.select(jCas, CommsIdentifier.class).size()); CommsIdentifier ip = JCasUtil.selectByIndex(jCas, CommsIdentifier.class, 0); assertEquals("fe80:0:0:0:204:61ff:fe9d:f156", ip.getCoveredText()); assertEquals("ipv6address", ip.getSubType()); }
@Test public void testCollapseLeadingZeroes() throws Exception { jCas.setDocumentText( "Here's an IPv6 address with collapsed leading zeroes: (fe80::204:61ff:fe9d:f156)"); processJCas(); assertEquals(1, JCasUtil.select(jCas, CommsIdentifier.class).size()); CommsIdentifier ip = JCasUtil.selectByIndex(jCas, CommsIdentifier.class, 0); assertEquals("fe80::204:61ff:fe9d:f156", ip.getCoveredText()); assertEquals("ipv6address", ip.getSubType()); }
@Test public void test() throws Exception { jCas.setDocumentText( "Document 123 was produced, and complemented letters 56, 59 and 57, 12 is not a resolution."); processJCas(); assertEquals(2, JCasUtil.select(jCas, DocumentReference.class).size()); DocumentReference dr1 = JCasUtil.selectByIndex(jCas, DocumentReference.class, 0); assertEquals("Document 123", dr1.getCoveredText()); DocumentReference dr2 = JCasUtil.selectByIndex(jCas, DocumentReference.class, 1); assertEquals("letters 56, 59 and 57", dr2.getCoveredText()); } }
@Test public void testPreciseConstructRelativePronoun() throws AnalysisEngineProcessException, ResourceInitializationException { String text = "The police want to catch a man who ran away."; // man - who jCas.setDocumentText(text); processJCas(); processJCasWithSieve(4); List<ReferenceTarget> targets = new ArrayList<>(JCasUtil.select(jCas, ReferenceTarget.class)); assertEquals(1, targets.size()); }
@Test public void testProperHeadMatchSameNumbers() throws AnalysisEngineProcessException, ResourceInitializationException { String text = "The 200 people visited and then the people left."; jCas.setDocumentText(text); processJCas(); processJCasWithSieve(8); List<ReferenceTarget> targets = new ArrayList<>(JCasUtil.select(jCas, ReferenceTarget.class)); assertEquals(1, targets.size()); }
@Test public void test() throws Exception { jCas.setDocumentText("Hello world, this is a test"); processJCas(MONGO, erd, COLLECTION, MONGO_COLL, TYPE, LOCATION); assertEquals(1, JCasUtil.select(jCas, Location.class).size()); Location l = JCasUtil.selectByIndex(jCas, Location.class, 0); assertEquals(WORLD, l.getValue()); assertEquals(WORLD, l.getCoveredText()); }
@Test public void testRegex() throws Exception { jCas.setDocumentText("Hello Sydney (Australia), this is a test"); processJCas(MONGO, erd, COLLECTION, MONGO_COLL, TYPE, LOCATION); assertEquals(1, JCasUtil.select(jCas, Location.class).size()); Location l = JCasUtil.selectByIndex(jCas, Location.class, 0); assertEquals("Sydney (Australia", l.getValue()); assertEquals("Sydney (Australia", l.getCoveredText()); }
@Test public void testInSentencePronoun() throws AnalysisEngineProcessException, ResourceInitializationException { String text = "He said he has not been in touch with her."; jCas.setDocumentText(text); processJCas(); processJCasWithSieve(3); List<ReferenceTarget> targets = new ArrayList<>(JCasUtil.select(jCas, ReferenceTarget.class)); assertEquals(1, targets.size()); }
@Test public void testMultipleWords() throws Exception { jCas.setDocumentText("Bill and Ben entered the room on a dark and windy night."); processJCas(MONGO, erd, COLLECTION, MONGO_COLL, TYPE, BUZZWORD); assertEquals(1, JCasUtil.select(jCas, Buzzword.class).size()); Buzzword b1 = JCasUtil.selectByIndex(jCas, Buzzword.class, 0); assertEquals("entered the room", b1.getValue()); assertEquals("entered the room", b1.getCoveredText()); }