/** * Get the text for the given offset. * * @param jCas to get the text from * @param offset * @return the text covered by the offset */ public static String getText(JCas jCas, Offset key) { return getText(jCas, key.getBegin(), key.getEnd()); }
/** * Get the text for the given offset. * * @param jCas to get the text from * @param offset * @return the text covered by the offset */ public static String getText(JCas jCas, Offset key) { return getText(jCas, key.getBegin(), key.getEnd()); }
@Test public void testGetOffsetText() throws UIMAException { JCas jCas = JCasFactory.createJCas(); jCas.setDocumentText("This is a test."); assertEquals("", OffsetUtil.getText(jCas, new Offset(0, 0))); assertEquals("This", OffsetUtil.getText(jCas, new Offset(0, 4))); assertEquals(" is a ", OffsetUtil.getText(jCas, new Offset(4, 10))); assertEquals("This is a test.", OffsetUtil.getText(jCas, new Offset(0, 15))); }