Access JCas Annotation list





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am developing an Apache UIMA v2 application to annotate documents.

I developed properly the process() method because I obtain the correct annotations (tested with debug and UIMA CAS Visual Debugger).


My application consists in a simple instantiation of the JCas object and the process of a document, i.e. a simple string in this case. Here's the code:



public class MainProgram {

public static void main(String args) {
try {
XMLInputSource in = new XMLInputSource("desc/dictionaryDescriptor.xml");
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);

JCas jcas = ae.newJCas();

jcas.setDocumentText("prova di a@gmail.com, timido, word, excel. ");

ae.process(jcas);
processResults(jcas);

ae.destroy();

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidXMLException e1) {
e1.printStackTrace();
} catch (ResourceInitializationException e2) {
e2.printStackTrace();
} catch (AnalysisEngineProcessException e3) {
e3.printStackTrace();
}


}

public static void processResults(JCas jcas) {
System.out.println("Done!");
// TODO read annotations from jcas
}
}


If I add a breakpoint inside the processResults() method I can see the content of jcas and the list of annotation:
debug jcas object




I want to access to the SubTypes list in the AnnotationIndex object, without taking care of the class type.


Here is an example through a specific type:



AnnotationIndex<Annotation> programIndex = jcas.getAnnotationIndex(Programma.type);
Iterator programIter = programIndex.iterator();

while(programIter.hasNext()) {
Programma p = (Programma) programIter.next();
}









share|improve this question

























  • What do you want to do with it once you have that list?

    – rec
    Oct 31 '18 at 10:34











  • I want to iterate that list and then check the type. Do you think that it's useless and it's better to use the iterator like I did? (I'm adding the code right now)

    – A. Wolf
    Oct 31 '18 at 10:38











  • Btw. you might want to have a look at uimaFIT (uima.apache.org/d/uimafit-current/…) - in particular if you are using UIMA v2. If you are using UIMA v3, you may want to look here: uima.apache.org/d/uimaj-current/version_3_users_guide.pdf (Section 4 - "Select" framework)

    – rec
    Oct 31 '18 at 10:38











  • I'm using UIMA v2. Do you think that is a good idea to switch to UIMA v3? I'm new to UIMA so I can't understand the impact of the differences. Thank you.

    – A. Wolf
    Oct 31 '18 at 10:46






  • 1





    If you use UIMAv2 together with uimaFIT, the uimaFIT (J)CasUtil "select" methods are pretty much as convenient as the UIMAv3 "select API". In fact, uimaFIT served as a role model for the v3 select API. In any case, you may want to use uimaFIT when you are writing your own UIMA components to profit from its parameter injection functionality.

    – rec
    Oct 31 '18 at 11:16


















0















I am developing an Apache UIMA v2 application to annotate documents.

I developed properly the process() method because I obtain the correct annotations (tested with debug and UIMA CAS Visual Debugger).


My application consists in a simple instantiation of the JCas object and the process of a document, i.e. a simple string in this case. Here's the code:



public class MainProgram {

public static void main(String args) {
try {
XMLInputSource in = new XMLInputSource("desc/dictionaryDescriptor.xml");
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);

JCas jcas = ae.newJCas();

jcas.setDocumentText("prova di a@gmail.com, timido, word, excel. ");

ae.process(jcas);
processResults(jcas);

ae.destroy();

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidXMLException e1) {
e1.printStackTrace();
} catch (ResourceInitializationException e2) {
e2.printStackTrace();
} catch (AnalysisEngineProcessException e3) {
e3.printStackTrace();
}


}

public static void processResults(JCas jcas) {
System.out.println("Done!");
// TODO read annotations from jcas
}
}


If I add a breakpoint inside the processResults() method I can see the content of jcas and the list of annotation:
debug jcas object




I want to access to the SubTypes list in the AnnotationIndex object, without taking care of the class type.


Here is an example through a specific type:



AnnotationIndex<Annotation> programIndex = jcas.getAnnotationIndex(Programma.type);
Iterator programIter = programIndex.iterator();

while(programIter.hasNext()) {
Programma p = (Programma) programIter.next();
}









share|improve this question

























  • What do you want to do with it once you have that list?

    – rec
    Oct 31 '18 at 10:34











  • I want to iterate that list and then check the type. Do you think that it's useless and it's better to use the iterator like I did? (I'm adding the code right now)

    – A. Wolf
    Oct 31 '18 at 10:38











  • Btw. you might want to have a look at uimaFIT (uima.apache.org/d/uimafit-current/…) - in particular if you are using UIMA v2. If you are using UIMA v3, you may want to look here: uima.apache.org/d/uimaj-current/version_3_users_guide.pdf (Section 4 - "Select" framework)

    – rec
    Oct 31 '18 at 10:38











  • I'm using UIMA v2. Do you think that is a good idea to switch to UIMA v3? I'm new to UIMA so I can't understand the impact of the differences. Thank you.

    – A. Wolf
    Oct 31 '18 at 10:46






  • 1





    If you use UIMAv2 together with uimaFIT, the uimaFIT (J)CasUtil "select" methods are pretty much as convenient as the UIMAv3 "select API". In fact, uimaFIT served as a role model for the v3 select API. In any case, you may want to use uimaFIT when you are writing your own UIMA components to profit from its parameter injection functionality.

    – rec
    Oct 31 '18 at 11:16














0












0








0








I am developing an Apache UIMA v2 application to annotate documents.

I developed properly the process() method because I obtain the correct annotations (tested with debug and UIMA CAS Visual Debugger).


My application consists in a simple instantiation of the JCas object and the process of a document, i.e. a simple string in this case. Here's the code:



public class MainProgram {

public static void main(String args) {
try {
XMLInputSource in = new XMLInputSource("desc/dictionaryDescriptor.xml");
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);

JCas jcas = ae.newJCas();

jcas.setDocumentText("prova di a@gmail.com, timido, word, excel. ");

ae.process(jcas);
processResults(jcas);

ae.destroy();

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidXMLException e1) {
e1.printStackTrace();
} catch (ResourceInitializationException e2) {
e2.printStackTrace();
} catch (AnalysisEngineProcessException e3) {
e3.printStackTrace();
}


}

public static void processResults(JCas jcas) {
System.out.println("Done!");
// TODO read annotations from jcas
}
}


If I add a breakpoint inside the processResults() method I can see the content of jcas and the list of annotation:
debug jcas object




I want to access to the SubTypes list in the AnnotationIndex object, without taking care of the class type.


Here is an example through a specific type:



AnnotationIndex<Annotation> programIndex = jcas.getAnnotationIndex(Programma.type);
Iterator programIter = programIndex.iterator();

while(programIter.hasNext()) {
Programma p = (Programma) programIter.next();
}









share|improve this question
















I am developing an Apache UIMA v2 application to annotate documents.

I developed properly the process() method because I obtain the correct annotations (tested with debug and UIMA CAS Visual Debugger).


My application consists in a simple instantiation of the JCas object and the process of a document, i.e. a simple string in this case. Here's the code:



public class MainProgram {

public static void main(String args) {
try {
XMLInputSource in = new XMLInputSource("desc/dictionaryDescriptor.xml");
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);

JCas jcas = ae.newJCas();

jcas.setDocumentText("prova di a@gmail.com, timido, word, excel. ");

ae.process(jcas);
processResults(jcas);

ae.destroy();

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidXMLException e1) {
e1.printStackTrace();
} catch (ResourceInitializationException e2) {
e2.printStackTrace();
} catch (AnalysisEngineProcessException e3) {
e3.printStackTrace();
}


}

public static void processResults(JCas jcas) {
System.out.println("Done!");
// TODO read annotations from jcas
}
}


If I add a breakpoint inside the processResults() method I can see the content of jcas and the list of annotation:
debug jcas object




I want to access to the SubTypes list in the AnnotationIndex object, without taking care of the class type.


Here is an example through a specific type:



AnnotationIndex<Annotation> programIndex = jcas.getAnnotationIndex(Programma.type);
Iterator programIter = programIndex.iterator();

while(programIter.hasNext()) {
Programma p = (Programma) programIter.next();
}






apache annotations uima






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 31 '18 at 10:45







A. Wolf

















asked Oct 30 '18 at 12:03









A. WolfA. Wolf

446619




446619













  • What do you want to do with it once you have that list?

    – rec
    Oct 31 '18 at 10:34











  • I want to iterate that list and then check the type. Do you think that it's useless and it's better to use the iterator like I did? (I'm adding the code right now)

    – A. Wolf
    Oct 31 '18 at 10:38











  • Btw. you might want to have a look at uimaFIT (uima.apache.org/d/uimafit-current/…) - in particular if you are using UIMA v2. If you are using UIMA v3, you may want to look here: uima.apache.org/d/uimaj-current/version_3_users_guide.pdf (Section 4 - "Select" framework)

    – rec
    Oct 31 '18 at 10:38











  • I'm using UIMA v2. Do you think that is a good idea to switch to UIMA v3? I'm new to UIMA so I can't understand the impact of the differences. Thank you.

    – A. Wolf
    Oct 31 '18 at 10:46






  • 1





    If you use UIMAv2 together with uimaFIT, the uimaFIT (J)CasUtil "select" methods are pretty much as convenient as the UIMAv3 "select API". In fact, uimaFIT served as a role model for the v3 select API. In any case, you may want to use uimaFIT when you are writing your own UIMA components to profit from its parameter injection functionality.

    – rec
    Oct 31 '18 at 11:16



















  • What do you want to do with it once you have that list?

    – rec
    Oct 31 '18 at 10:34











  • I want to iterate that list and then check the type. Do you think that it's useless and it's better to use the iterator like I did? (I'm adding the code right now)

    – A. Wolf
    Oct 31 '18 at 10:38











  • Btw. you might want to have a look at uimaFIT (uima.apache.org/d/uimafit-current/…) - in particular if you are using UIMA v2. If you are using UIMA v3, you may want to look here: uima.apache.org/d/uimaj-current/version_3_users_guide.pdf (Section 4 - "Select" framework)

    – rec
    Oct 31 '18 at 10:38











  • I'm using UIMA v2. Do you think that is a good idea to switch to UIMA v3? I'm new to UIMA so I can't understand the impact of the differences. Thank you.

    – A. Wolf
    Oct 31 '18 at 10:46






  • 1





    If you use UIMAv2 together with uimaFIT, the uimaFIT (J)CasUtil "select" methods are pretty much as convenient as the UIMAv3 "select API". In fact, uimaFIT served as a role model for the v3 select API. In any case, you may want to use uimaFIT when you are writing your own UIMA components to profit from its parameter injection functionality.

    – rec
    Oct 31 '18 at 11:16

















What do you want to do with it once you have that list?

– rec
Oct 31 '18 at 10:34





What do you want to do with it once you have that list?

– rec
Oct 31 '18 at 10:34













I want to iterate that list and then check the type. Do you think that it's useless and it's better to use the iterator like I did? (I'm adding the code right now)

– A. Wolf
Oct 31 '18 at 10:38





I want to iterate that list and then check the type. Do you think that it's useless and it's better to use the iterator like I did? (I'm adding the code right now)

– A. Wolf
Oct 31 '18 at 10:38













Btw. you might want to have a look at uimaFIT (uima.apache.org/d/uimafit-current/…) - in particular if you are using UIMA v2. If you are using UIMA v3, you may want to look here: uima.apache.org/d/uimaj-current/version_3_users_guide.pdf (Section 4 - "Select" framework)

– rec
Oct 31 '18 at 10:38





Btw. you might want to have a look at uimaFIT (uima.apache.org/d/uimafit-current/…) - in particular if you are using UIMA v2. If you are using UIMA v3, you may want to look here: uima.apache.org/d/uimaj-current/version_3_users_guide.pdf (Section 4 - "Select" framework)

– rec
Oct 31 '18 at 10:38













I'm using UIMA v2. Do you think that is a good idea to switch to UIMA v3? I'm new to UIMA so I can't understand the impact of the differences. Thank you.

– A. Wolf
Oct 31 '18 at 10:46





I'm using UIMA v2. Do you think that is a good idea to switch to UIMA v3? I'm new to UIMA so I can't understand the impact of the differences. Thank you.

– A. Wolf
Oct 31 '18 at 10:46




1




1





If you use UIMAv2 together with uimaFIT, the uimaFIT (J)CasUtil "select" methods are pretty much as convenient as the UIMAv3 "select API". In fact, uimaFIT served as a role model for the v3 select API. In any case, you may want to use uimaFIT when you are writing your own UIMA components to profit from its parameter injection functionality.

– rec
Oct 31 '18 at 11:16





If you use UIMAv2 together with uimaFIT, the uimaFIT (J)CasUtil "select" methods are pretty much as convenient as the UIMAv3 "select API". In fact, uimaFIT served as a role model for the v3 select API. In any case, you may want to use uimaFIT when you are writing your own UIMA components to profit from its parameter injection functionality.

– rec
Oct 31 '18 at 11:16












1 Answer
1






active

oldest

votes


















0














You can use the JCasUtil to extract the annotations of the JCas:



JCasUtil.select(jCas, Annotation.class).stream()....


and with the getType() method of the annotation you can check for the type of the annotation.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53063907%2faccess-jcas-annotation-list%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can use the JCasUtil to extract the annotations of the JCas:



    JCasUtil.select(jCas, Annotation.class).stream()....


    and with the getType() method of the annotation you can check for the type of the annotation.






    share|improve this answer




























      0














      You can use the JCasUtil to extract the annotations of the JCas:



      JCasUtil.select(jCas, Annotation.class).stream()....


      and with the getType() method of the annotation you can check for the type of the annotation.






      share|improve this answer


























        0












        0








        0







        You can use the JCasUtil to extract the annotations of the JCas:



        JCasUtil.select(jCas, Annotation.class).stream()....


        and with the getType() method of the annotation you can check for the type of the annotation.






        share|improve this answer













        You can use the JCasUtil to extract the annotations of the JCas:



        JCasUtil.select(jCas, Annotation.class).stream()....


        and with the getType() method of the annotation you can check for the type of the annotation.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 19:38









        Jasper HuzenJasper Huzen

        658412




        658412
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53063907%2faccess-jcas-annotation-list%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?