0

我有 UIMA 对象,其中包含带有注释的文件数量

我正在迭代这个对象并将内容保存在 arraylist 中

Iterator Iter = UIMA.iterator();
    while (Iter.hasNext()) 
    {
        FirstName fn = (FirstName) Iter.next();
            String name=fn.getName();//It will return the name 
            vc.add(name); //Adding to arraylist
           System.out.println(name);
         }
         return vc;

这里的问题是如果我打印出名称。所有预期的名称都打印得很好但是向量包含重复项,如下所示

For firstfile    
name1 name2 name3
For second file
name1 name2 name3 name12 name22 name23
For 3rd file
name1 name2 name3 name12 name22 name23 name31 name32 name33

为什么这些元素要添加多次?

4

1 回答 1

2
Iterator Iter = UIMA.iterator();

vc = new ArrayList(); // HERE is where you need to create your vc object
while (Iter.hasNext()) 
{
    FirstName fn = (FirstName) Iter.next();
        String name=fn.getName();//It will return the name 
        vc.add(name);
       System.out.println(name);
     }
     return vc;
于 2013-10-28T13:19:44.797 回答