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 2013/11/02 12:08:17 UTC

[jira] [Updated] (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 updated UIMA-3403:
---------------------------------------------

    Description: 
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}


  was:
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.

@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);
            }
        }
    }



> 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
>            Reporter: Torsten Zesch
>
> 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#6144)