/** * @generated * @param jcas JCas to which this Feature Structure belongs * @param begin offset to the begin spot in the SofA * @param end offset to the end spot in the SofA */ public Nationality(JCas jcas, int begin, int end) { super(jcas); setBegin(begin); setEnd(end); readObject(); }
@Test public void test() throws Exception { jCas.setDocumentText("Pierre is French"); Person p = new Person(jCas); p.setBegin(0); p.setEnd(6); p.setValue("Pierre"); p.addToIndexes(); Nationality n = new Nationality(jCas); n.setBegin(10); n.setEnd(16); n.setValue("French"); n.setCountryCode("fra"); n.addToIndexes(); ae.process(jCas); assertEquals(1, JCasUtil.select(jCas, Location.class).size()); Location l = JCasUtil.selectByIndex(jCas, Location.class, 0); assertEquals("French", l.getValue()); assertNotNull(l.getGeoJson()); } }
@Test public void testNationalityPeopleKeepOriginal() throws Exception { jCas.setDocumentText("The Scottish people voted in an independence referendum"); Nationality n = new Nationality(jCas, 4, 12); n.addToIndexes(); processJCas(People.PARAM_REMOVE_ORIGINAL, false); assertEquals(1, JCasUtil.select(jCas, Nationality.class).size()); assertEquals("Scottish", JCasUtil.selectByIndex(jCas, Nationality.class, 0).getCoveredText()); assertEquals(1, JCasUtil.select(jCas, Organisation.class).size()); assertEquals( "Scottish people", JCasUtil.selectByIndex(jCas, Organisation.class, 0).getCoveredText()); }
@Test public void testNationalityPeople() throws Exception { jCas.setDocumentText("The Scottish people voted in an independence referendum"); Nationality n = new Nationality(jCas, 4, 12); n.addToIndexes(); processJCas(); assertEquals(0, JCasUtil.select(jCas, Nationality.class).size()); assertEquals(1, JCasUtil.select(jCas, Organisation.class).size()); assertEquals( "Scottish people", JCasUtil.selectByIndex(jCas, Organisation.class, 0).getCoveredText()); }
@Test public void test() throws Exception { jCas.setDocumentText( "James is a BRITISH national. Last month, he met an Irish bloke in the pub. He is friends with Bob, who is an Spanish."); ae.process(jCas); assertEquals(3, JCasUtil.select(jCas, Nationality.class).size()); Nationality british = JCasUtil.selectByIndex(jCas, Nationality.class, 0); assertNotNull(british); assertEquals("BRITISH", british.getCoveredText()); assertEquals("BRITISH", british.getValue()); assertEquals("GBR", british.getCountryCode()); Nationality irish = JCasUtil.selectByIndex(jCas, Nationality.class, 1); assertNotNull(irish); assertEquals("Irish", irish.getCoveredText()); assertEquals("Irish", irish.getValue()); assertEquals("IRL", irish.getCountryCode()); Nationality spanish = JCasUtil.selectByIndex(jCas, Nationality.class, 2); assertNotNull(spanish); assertEquals("Spanish", spanish.getCoveredText()); assertEquals("Spanish", spanish.getValue()); assertEquals("ESP", spanish.getCountryCode()); }
@Test public void testEnhanceNationality() { Nationality n = new Nationality(jCas); n.setValue("British"); Mention m = new Mention(n); genderEnhancer.enhance(m); assertEquals(Gender.UNKNOWN, m.getGender()); }
return Optional.of(new Money(jCas)); case "Nationality": return Optional.of(new Nationality(jCas)); case "Organisation": return Optional.of(new Organisation(jCas));
/** * @generated * @param jcas JCas to which this Feature Structure belongs */ public Nationality(JCas jcas) { super(jcas); readObject(); }
@Test public void test() throws Exception { jCas.setDocumentText("British Prime Minister Theresa May called for a snap election"); Nationality n = new Nationality(jCas, 0, 7); n.addToIndexes(); Person p = new Person(jCas, 8, 34); p.addToIndexes(); processJCas(); assertEquals(0, JCasUtil.select(jCas, Nationality.class).size()); assertEquals(1, JCasUtil.select(jCas, Person.class).size()); assertEquals( "British Prime Minister Theresa May", JCasUtil.selectByIndex(jCas, Person.class, 0).getCoveredText()); } }
@Test public void testWithText() throws Exception { jCas.setDocumentText( "James is a BRITISH national. Last month, he met an Irish bloke in the pub. He is friends with Bob, who is an Spanish."); new Text(jCas, 30, 75).addToIndexes(); new Text(jCas, 76, jCas.getDocumentText().length()).addToIndexes(); ae.process(jCas); assertEquals(2, JCasUtil.select(jCas, Nationality.class).size()); Nationality irish = JCasUtil.selectByIndex(jCas, Nationality.class, 0); assertNotNull(irish); assertEquals("Irish", irish.getCoveredText()); assertEquals("Irish", irish.getValue()); assertEquals("IRL", irish.getCountryCode()); Nationality spanish = JCasUtil.selectByIndex(jCas, Nationality.class, 1); assertNotNull(spanish); assertEquals("Spanish", spanish.getCoveredText()); assertEquals("Spanish", spanish.getValue()); assertEquals("ESP", spanish.getCountryCode()); } }
return Optional.of(new Money(jCas)); case "Nationality": return Optional.of(new Nationality(jCas)); case "Organisation": return Optional.of(new Organisation(jCas));
/** * Internal - constructor used by generator * * @generated * @param addr low level Feature Structure reference * @param type the type of this Feature Structure */ public Nationality(int addr, TOP_Type type) { super(addr, type); readObject(); }
/** * @generated * @param jcas JCas to which this Feature Structure belongs * @param begin offset to the begin spot in the SofA * @param end offset to the end spot in the SofA */ public Nationality(JCas jcas, int begin, int end) { super(jcas); setBegin(begin); setEnd(end); readObject(); }
/** * @generated * @param jcas JCas to which this Feature Structure belongs */ public Nationality(JCas jcas) { super(jcas); readObject(); }
/** * Internal - constructor used by generator * * @generated * @param addr low level Feature Structure reference * @param type the type of this Feature Structure */ public Nationality(int addr, TOP_Type type) { super(addr, type); readObject(); }