private Person addPersonToHeaderBlock( final String s, final int offset, final StringBuilder sb, final JCas jCas) { final Person p = new Person(jCas); return addToHeaderBlock(s, offset, sb, p); }
private Person addPersonToHeaderBlock( final String s, final int offset, final StringBuilder sb, final JCas jCas) { final Person p = new Person(jCas); return addToHeaderBlock(s, offset, sb, p); }
@Override protected Person create(JCas jCas, Matcher matcher) { return new Person(jCas); }
@Test public void testFemale() throws AnalysisEngineProcessException, ResourceInitializationException { jCas.setDocumentText("Alice Samantha"); Person p = new Person(jCas); p.setBegin(0); p.setEnd(14); p.addToIndexes(); processJCas(AddGenderToPerson.KEY_GENDER_MULTIPLICITY, erd); Collection<Person> select = JCasUtil.select(jCas, Person.class); assertEquals(1, select.size()); Person out = select.iterator().next(); assertEquals("FEMALE", out.getGender()); }
@Test public void testMixed() throws AnalysisEngineProcessException, ResourceInitializationException { jCas.setDocumentText("Alice Brian Smith"); Person p = new Person(jCas); p.setBegin(0); p.setEnd(17); p.addToIndexes(); processJCas(AddGenderToPerson.KEY_GENDER_MULTIPLICITY, erd); Collection<Person> select = JCasUtil.select(jCas, Person.class); assertEquals(1, select.size()); Person out = select.iterator().next(); assertEquals("UNKNOWN", out.getGender()); }
@Test public void testMale() throws AnalysisEngineProcessException, ResourceInitializationException { jCas.setDocumentText("Professor Brian Cox"); Person p = new Person(jCas); p.setBegin(10); p.setEnd(19); p.addToIndexes(); processJCas(AddGenderToPerson.KEY_GENDER_MULTIPLICITY, erd); Collection<Person> select = JCasUtil.select(jCas, Person.class); assertEquals(1, select.size()); Person out = select.iterator().next(); assertEquals("MALE", out.getGender()); }
public static Person createPerson(JCas jCas, int begin, int end, String value) { Person p = new Person(jCas); p.setValue(value); p.setBegin(begin); p.setEnd(end); p.addToIndexes(); return p; }
@Test public void testMiddle() throws Exception { // Test cases where the brackets appear in the middle (should ignore and not split) jCas.setDocumentText("His name was Andrew (Drew) Smith"); Person p = new Person(jCas, 13, 32); p.addToIndexes(); processJCas(); assertEquals(1, JCasUtil.select(jCas, Person.class).size()); assertEquals(p, JCasUtil.selectByIndex(jCas, Person.class, 0)); }
@Test public void testStart() throws Exception { // Test cases where the brackets appear at the start (should ignore and not split) jCas.setDocumentText("His name was (Andrew Smith) Drew"); Person p = new Person(jCas, 13, 32); p.addToIndexes(); processJCas(); assertEquals(1, JCasUtil.select(jCas, Person.class).size()); assertEquals(p, JCasUtil.selectByIndex(jCas, Person.class, 0)); }
@Test public void testSingle() throws AnalysisEngineProcessException, ResourceInitializationException { jCas.setDocumentText("They refered to him as Sir John Smith"); Person p = new Person(jCas); p.setBegin(jCas.getDocumentText().indexOf("John Smith")); p.setEnd(p.getBegin() + "John Smith".length()); p.addToIndexes(); processJCas(); Collection<Person> select = JCasUtil.select(jCas, Person.class); assertEquals(1, select.size()); Person out = select.iterator().next(); assertEquals("Sir", out.getTitle()); assertEquals(jCas.getDocumentText().indexOf("Sir"), out.getBegin()); }
@Test public void testSingleExisting() throws AnalysisEngineProcessException, ResourceInitializationException { jCas.setDocumentText("They refered to him as Sir John Smith"); Person p = new Person(jCas); p.setBegin(jCas.getDocumentText().indexOf("Sir John Smith")); p.setEnd(p.getBegin() + "Sir John Smith".length()); p.addToIndexes(); processJCas(); Collection<Person> select = JCasUtil.select(jCas, Person.class); assertEquals(1, select.size()); Person out = select.iterator().next(); assertEquals("Sir", out.getTitle()); assertEquals("Sir John Smith", out.getCoveredText()); }
@Test public void testSingleExisting2() throws AnalysisEngineProcessException, ResourceInitializationException { jCas.setDocumentText("They refered to him as Mr. John Smith"); Person p = new Person(jCas); p.setBegin(jCas.getDocumentText().indexOf("Mr. John Smith")); p.setEnd(p.getBegin() + "Mr. John Smith".length()); p.addToIndexes(); processJCas(); Collection<Person> select = JCasUtil.select(jCas, Person.class); assertEquals(1, select.size()); Person out = select.iterator().next(); assertEquals("Mr", out.getTitle()); assertEquals("Mr. John Smith", out.getCoveredText()); }
@Test public void test() throws AnalysisEngineProcessException, ResourceInitializationException { jCas.setDocumentText("John went to London. I saw John there."); Person p = new Person(jCas); p.setBegin(0); p.setEnd(4); p.setValue("John"); p.addToIndexes(); processJCas(); List<Entity> select = new ArrayList<>(JCasUtil.select(jCas, Person.class)); assertEquals(2, select.size()); assertEquals("John", select.get(0).getValue()); assertEquals("John", select.get(1).getValue()); }
private void createDocument() { DocumentAnnotation da = (DocumentAnnotation) jCas.getDocumentAnnotationFs(); da.setSourceUri(TEST1_TXT); CommsIdentifier ci = new CommsIdentifier(jCas); ci.addToIndexes(); Person p = new Person(jCas); p.addToIndexes(); }
@Test public void testEntities() throws UIMAException { final Person s = new Person(jCas); s.setValue("source"); s.addToIndexes(); SimplePipeline.runPipeline(jCas, AnalysisEngineFactory.createEngine(Entities.class)); }
@Test public void test4() throws UIMAException { createPOS(); Person person = new Person(jCas, 0, 2); // He person.addToIndexes(); Money money = new Money(jCas, 59, 71); // $1.8 billion money.addToIndexes(); Temporal date = new Temporal(jCas, 75, 84); // September date.addToIndexes(); processJCas(NPVNP.PARAM_ONLY_EXISTING, true); assertEquals(0, JCasUtil.select(jCas, Relation.class).size()); }
@Test public void testEnhancePerson() { Person p = new Person(jCas); p.setValue("Sir Lancelot"); p.setTitle("Sir"); Mention m = new Mention(p); genderEnhancer.enhance(m); assertEquals(Gender.M, m.getGender()); }
@Test public void testOne() throws Exception { jCas.setDocumentText("His name was Andrew Smith (Andy)"); Person p = new Person(jCas, 13, 32); p.addToIndexes(); processJCas(); assertEquals(2, JCasUtil.select(jCas, Person.class).size()); Person p1 = JCasUtil.selectByIndex(jCas, Person.class, 0); assertEquals("Andrew Smith", p1.getCoveredText()); Person p2 = JCasUtil.selectByIndex(jCas, Person.class, 1); assertEquals("Andy", p2.getCoveredText()); assertEquals(p1.getReferent(), p2.getReferent()); }
@Test public void testSinglePersonNoReferences() throws Exception { jCas.setDocumentText("Mr Simon Brown, was caught stealing sausages. Brown was found guilty."); Person p = new Person(jCas, 0, 14); p.addToIndexes(); processJCas(); assertEquals(2, JCasUtil.select(jCas, Person.class).size()); Person p1 = JCasUtil.selectByIndex(jCas, Person.class, 0); assertEquals("Mr Simon Brown", p1.getCoveredText()); Person p2 = JCasUtil.selectByIndex(jCas, Person.class, 1); assertEquals("Brown", p2.getCoveredText()); assertNotNull(p1.getReferent()); assertEquals(p1.getReferent(), p2.getReferent()); }
@Test public void testRelations() throws UIMAException { final Person s = new Person(jCas); s.setValue("source"); final Location t = new Location(jCas); t.setValue("target"); final Relation r = new Relation(jCas); r.setSource(s); r.setTarget(t); r.setRelationshipType("check"); r.addToIndexes(); SimplePipeline.runPipeline(jCas, AnalysisEngineFactory.createEngine(Relations.class)); }