You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by "Richard Eckart de Castilho (JIRA)" <de...@uima.apache.org> on 2014/03/02 12:48:20 UTC
[jira] [Resolved] (UIMA-3403) selectPreceding() does not return
preceding for last annotation
[ https://issues.apache.org/jira/browse/UIMA-3403?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Richard Eckart de Castilho resolved UIMA-3403.
----------------------------------------------
Resolution: Fixed
Assignee: Richard Eckart de Castilho
> selectPreceding() does not return preceding for last annotation
> ---------------------------------------------------------------
>
> Key: UIMA-3403
> URL: https://issues.apache.org/jira/browse/UIMA-3403
> Project: UIMA
> Issue Type: Bug
> Components: uimaFIT
> Affects Versions: 2.0.0uimaFIT
> Reporter: Torsten Zesch
> Assignee: Richard Eckart de Castilho
> Fix For: 2.0.1uimaFIT
>
>
> selectPreceding() does not return the preceding element for the last element in the CAS if one is looking for a different annotation type than the anchor.
> See the test below.
> If the anchor is a token and I want the preceding tokens, everything is fine, but when I use a token anchor to get the preceding lemmas, no lemma is returned for the last token in the CAS.
> Offset are exactly the same so the behaviour is unexpected.
> {noformat}
> @Test
> public void test()
> throws Exception
> {
> String testDocument = "This is a test document .\nIt is quite short .\n";
> AnalysisEngine engine = AnalysisEngineFactory.createEngine(NoOpAnnotator.class);
> JCas jcas = engine.newJCas();
> TokenBuilder<Token, Sentence> tb = TokenBuilder.create(Token.class, Sentence.class);
> tb.buildTokens(jcas, testDocument);
> engine.process(jcas);
>
> for (Token token : JCasUtil.select(jcas, Token.class)) {
> Lemma lemma = new Lemma(jcas, token.getBegin(), token.getEnd());
> lemma.addToIndexes();
> }
> for (Token token : JCasUtil.select(jcas, Token.class)) {
> // try {
> // List<Token> previous = JCasUtil.selectPreceding(Token.class, token, 1);
> // System.out.println(previous.get(0).getCoveredText());
> // }
> // catch (IndexOutOfBoundsException e) {
> // System.out.println(token);
> // }
> try {
> List<Lemma> previous = JCasUtil.selectPreceding(Lemma.class, token, 1);
> System.out.println(previous.get(0).getCoveredText());
> }
> catch (IndexOutOfBoundsException e) {
> System.out.println(token);
> }
> }
> }
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)