@Test public void testPreciseConstructAcronym() throws AnalysisEngineProcessException, ResourceInitializationException { String text = "The British Broadcasting Corporation or the BBC if you prefer shows television programmes."; // British Broadcasting Corporation - BBC jCas.setDocumentText(text); // We need these in otherwise we just get one long setence from the mention detector Organisation beeb = new Organisation(jCas); beeb.setBegin(text.indexOf("British Broadcasting Corporation")); beeb.setEnd(beeb.getBegin() + "British Broadcasting Corporation".length()); beeb.addToIndexes(); Organisation bbc = new Organisation(jCas); bbc.setBegin(text.indexOf("BBC")); bbc.setEnd(bbc.getBegin() + "BBC".length()); bbc.addToIndexes(); processJCas(); processJCasWithSieve(4); List<ReferenceTarget> targets = new ArrayList<>(JCasUtil.select(jCas, ReferenceTarget.class)); assertEquals(1, targets.size()); List<Organisation> orgs = new ArrayList<Organisation>(JCasUtil.select(jCas, Organisation.class)); assertEquals(2, orgs.size()); assertNotNull(orgs.get(0).getReferent()); assertEquals( orgs.get(0).getReferent().getInternalId(), orgs.get(1).getReferent().getInternalId()); }
@Test public void testRelaxedStringMatch() throws AnalysisEngineProcessException, ResourceInitializationException { String text = "The University of Warwick is near Coventry and that was the University at which Chris studied."; // university of warwick - university jCas.setDocumentText(text); Person chris = new Person(jCas); chris.setBegin(text.indexOf("Chris")); chris.setEnd(chris.getBegin() + "Chris".length()); chris.addToIndexes(); Organisation uow = new Organisation(jCas); uow.setBegin(text.indexOf("University of Warwick")); uow.setEnd(uow.getBegin() + "University of Warwick".length()); uow.addToIndexes(); Organisation u = new Organisation(jCas); u.setBegin(text.indexOf("University", uow.getEnd())); u.setEnd(u.getBegin() + "University".length()); u.addToIndexes(); processJCas(); processJCasWithSieve(2); List<ReferenceTarget> targets = new ArrayList<>(JCasUtil.select(jCas, ReferenceTarget.class)); List<Organisation> location = new ArrayList<>(JCasUtil.select(jCas, Organisation.class)); assertEquals(1, targets.size()); assertSame(targets.get(0), location.get(0).getReferent()); assertSame(targets.get(0), location.get(1).getReferent()); }