You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Administrator <ro...@gmail.com> on 2012/11/15 18:37:29 UTC
Arrays/Lists of custom types
Hello dear uima user,
Lets say i defined the types Word and Sentence. How to add a feature to the type Sentence which holds multiple Words? For instance a list of Words.
Thanks in advance
Roman
Re: Arrays/Lists of custom types
Posted by Marshall Schor <ms...@schor.com>.
+1
-Marshall
On 11/16/2012 8:45 AM, Richard Eckart de Castilho wrote:
> I'd recommend to use FSList only when it is necessary that elements are added to the list at some point. If the number of elements in your list are known when the feature is set and no elements need to be appended later, I would recommend FSArray.
>
> -- Richard
>
> Am 16.11.2012 um 02:15 schrieb Himanshu Gahlot <hi...@gmail.com>:
>
>> Create a feature of type NonEmptyFSList in your Sentence type and name it
>> 'words'. Now in your sentence annotator, iterate over all the words in this
>> sentence, put them in a List<Word>, create an FSList using your List<Word>,
>> and set this FSList as the 'words' feature in your Sentence. Some untested
>> code to help you out:
>>
>> List<Word> wordList = //your list of words in the current sentence
>> FSList wordFSList = FSCollectionFactory.createFSList(aJCas, wordList);
>> sentence.setWords(wordFSList);
>>
>> Note that I am using FSCollectionFactory class from uimafit (
>> http://uimafit.googlecode.com/svn-history/r623/trunk/apidocs/org/uimafit/util/FSCollectionFactory.html
>> ).
>>
>> Himanshu
>>
>>
>> On Thu, Nov 15, 2012 at 9:37 AM, Administrator <
>> roman.alexandrovich.mueller@gmail.com> wrote:
>>
>>> Hello dear uima user,
>>>
>>> Lets say i defined the types Word and Sentence. How to add a feature to
>>> the type Sentence which holds multiple Words? For instance a list of Words.
>>>
>>> Thanks in advance
>>> Roman
>
Re: Arrays/Lists of custom types
Posted by Richard Eckart de Castilho <ec...@ukp.informatik.tu-darmstadt.de>.
I'd recommend to use FSList only when it is necessary that elements are added to the list at some point. If the number of elements in your list are known when the feature is set and no elements need to be appended later, I would recommend FSArray.
-- Richard
Am 16.11.2012 um 02:15 schrieb Himanshu Gahlot <hi...@gmail.com>:
> Create a feature of type NonEmptyFSList in your Sentence type and name it
> 'words'. Now in your sentence annotator, iterate over all the words in this
> sentence, put them in a List<Word>, create an FSList using your List<Word>,
> and set this FSList as the 'words' feature in your Sentence. Some untested
> code to help you out:
>
> List<Word> wordList = //your list of words in the current sentence
> FSList wordFSList = FSCollectionFactory.createFSList(aJCas, wordList);
> sentence.setWords(wordFSList);
>
> Note that I am using FSCollectionFactory class from uimafit (
> http://uimafit.googlecode.com/svn-history/r623/trunk/apidocs/org/uimafit/util/FSCollectionFactory.html
> ).
>
> Himanshu
>
>
> On Thu, Nov 15, 2012 at 9:37 AM, Administrator <
> roman.alexandrovich.mueller@gmail.com> wrote:
>
>> Hello dear uima user,
>>
>> Lets say i defined the types Word and Sentence. How to add a feature to
>> the type Sentence which holds multiple Words? For instance a list of Words.
>>
>> Thanks in advance
>> Roman
--
-------------------------------------------------------------------
Richard Eckart de Castilho
Technical Lead
Ubiquitous Knowledge Processing Lab (UKP-TUD)
FB 20 Computer Science Department
Technische Universität Darmstadt
Hochschulstr. 10, D-64289 Darmstadt, Germany
phone [+49] (0)6151 16-7477, fax -5455, room S2/02/B117
eckart@ukp.informatik.tu-darmstadt.de
www.ukp.tu-darmstadt.de
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
-------------------------------------------------------------------
Re: Arrays/Lists of custom types
Posted by Himanshu Gahlot <hi...@gmail.com>.
Create a feature of type NonEmptyFSList in your Sentence type and name it
'words'. Now in your sentence annotator, iterate over all the words in this
sentence, put them in a List<Word>, create an FSList using your List<Word>,
and set this FSList as the 'words' feature in your Sentence. Some untested
code to help you out:
List<Word> wordList = //your list of words in the current sentence
FSList wordFSList = FSCollectionFactory.createFSList(aJCas, wordList);
sentence.setWords(wordFSList);
Note that I am using FSCollectionFactory class from uimafit (
http://uimafit.googlecode.com/svn-history/r623/trunk/apidocs/org/uimafit/util/FSCollectionFactory.html
).
Himanshu
On Thu, Nov 15, 2012 at 9:37 AM, Administrator <
roman.alexandrovich.mueller@gmail.com> wrote:
> Hello dear uima user,
>
> Lets say i defined the types Word and Sentence. How to add a feature to
> the type Sentence which holds multiple Words? For instance a list of Words.
>
> Thanks in advance
> Roman