/** * @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 Quantity(JCas jcas, int begin, int end) { super(jcas); setBegin(begin); setEnd(end); 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 Quantity(JCas jcas, int begin, int end) { super(jcas); setBegin(begin); setEnd(end); readObject(); }
@Test public void testRemoveQuantity() throws UIMAException { jCas.setDocumentText("The weapons were found 20 miles north of London"); Quantity q = new Quantity(jCas); q.setBegin(23); q.setEnd(31); q.setSubType("distance"); q.addToIndexes(); Location l = new Location(jCas, 41, 47); l.addToIndexes(); processJCas(ExpandLocationToDescription.PARAM_REMOVE_QUANTITY, true); assertEquals("20 miles north of London", l.getCoveredText()); assertEquals(0, JCasUtil.select(jCas, Quantity.class).size()); }
@Test public void test() throws UIMAException { jCas.setDocumentText("The weapons were found 50 miles south-west of London"); Quantity q = new Quantity(jCas); q.setBegin(23); q.setEnd(31); q.setSubType("distance"); q.addToIndexes(); Location l = new Location(jCas, 46, 52); l.addToIndexes(); processJCas(); assertEquals("50 miles south-west of London", l.getCoveredText()); assertEquals(1, JCasUtil.select(jCas, Quantity.class).size()); }
@Test public void testMarked() throws UIMAException { Quantity q = new Quantity(jCas); q.setBegin(18); q.setEnd(21); q.addToIndexes(); Buzzword e = new Buzzword(jCas); e.setBegin(25); e.setEnd(36); e.addToIndexes(); processJCas(); assertEquals(2, JCasUtil.select(jCas, Entity.class).size()); assertEquals(1, JCasUtil.select(jCas, Relation.class).size()); Relation r = JCasUtil.selectByIndex(jCas, Relation.class, 0); assertEquals(18, r.getBegin()); assertEquals(q, r.getSource()); assertEquals(36, e.getEnd()); assertEquals(e, r.getTarget()); assertEquals("QUANTITY", r.getRelationshipType()); } }
@Test public void testUnmarked() throws UIMAException { Quantity q = new Quantity(jCas); q.setBegin(18); q.setEnd(21); q.addToIndexes(); processJCas(); assertAnnotations(2, Entity.class, new TestEntity<>(1, "blue powder")); assertEquals(1, JCasUtil.select(jCas, Relation.class).size()); Relation r = JCasUtil.selectByIndex(jCas, Relation.class, 0); assertEquals(18, r.getBegin()); assertEquals(q, r.getSource()); assertEquals(36, r.getEnd()); assertNotNull(r.getTarget()); assertEquals("QUANTITY", r.getRelationshipType()); }
public static Quantity createDistanceQuantity( JCas jCas, int begin, int end, String value, int quantity, String unit, double normalizedQuantity) { Quantity q = new Quantity(jCas); q.setBegin(begin); q.setEnd(end); q.setConfidence(1.0); q.setValue(value); q.setQuantity(quantity); q.setUnit(unit); q.setNormalizedQuantity(normalizedQuantity); q.setNormalizedUnit("m"); q.setSubType("length"); q.addToIndexes(); return q; }
public static Quantity createWeightQuantity( JCas jCas, int begin, int end, String value, double quantity, String unit, double normalizedQuantity) { Quantity q = new Quantity(jCas); q.setBegin(begin); q.setEnd(end); q.setConfidence(1.0); q.setValue(value); q.setQuantity(quantity); q.setUnit(unit); q.setNormalizedQuantity(normalizedQuantity); q.setNormalizedUnit("kg"); q.setSubType(WEIGHT); q.addToIndexes(); return q; }