From: Danica D. <d.d...@dc...> - 2007-08-29 14:18:09
|
It should return String. Check your spelling. Do you get any exceptions? I've just tested this part and works fine: AnnotationSet testAnn = document .getAnnotations().get("Token"); for (Annotation ann:testAnn){ Object category = ann.getFeatures().get("category"); System.out.println("category returns: "+category.getClass()); System.out.println("category is: "+(String)category); } The output is: category type: class java.lang.String category is: NN category type: class java.lang.String category is: VBP .... danica ch...@ha... wrote: > Danica, > > Thanks, > > but what is the > map.get("category"); > > supposed to return? I cannot cast this Object to a String > > Thanks, > > Chris > > ----- Original Message ----- > From: Danica Damljanovic <D.D...@dc...> > Date: Tuesday, August 28, 2007 12:44 pm > Subject: Re: [gate-users] determining a feature of annotations > To: ch...@ha... > Cc: gat...@li... > > >> To get all annotations of type token you do something like: >> AnnotationSet annotations = document >> .getAnnotations().get("Token"); >> >> than to acces the features: >> for (Annotation ann:annotations){ >> FeatureMap map = ann.getFeatures(); >> String catFeature = map.get("category"); >> //check whatever you need here >> } >> >> If you need the list of all features, you can list keys of the >> variable >> map in the example, and then get the values one by one. >> >> HTH, >> Danica >> >> >> ch...@ha... wrote: >> >>> Hello, >>> >>> I have build an application, saved it, and am able to call it >>> >> from java >> >>> using the basic batch processing sample. Some of my PR add pos >>> >> types> to features for each token. Does anyone have any sample >> code to check >> >>> each annotation to see what features it contains and see what the >>> >> value> of a certain feature is. IN my case I want to see if the >> "category"> feature of the Token annotations is a verb type. >> >>> Thanks, >>> Chris >>> >>> ------------------------------------------------------------------ >>> >> ------- >> >>> This SF.net email is sponsored by: Splunk Inc. >>> Still grepping through log files to find problems? Stop. >>> Now Search log events and configuration files using AJAX and a >>> >> browser.> Download your FREE copy of Splunk now >> >> http://get.splunk.com/> >> _______________________________________________> GATE-users mailing >> list> GAT...@li... >> >>> https://lists.sourceforge.net/lists/listinfo/gate-users >>> >>> > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > GATE-users mailing list > GAT...@li... > https://lists.sourceforge.net/lists/listinfo/gate-users > |