update attribute a element in arraylist on java ?

Posted by tiendv on Stack Overflow See other posts from Stack Overflow or by tiendv
Published on 2010-06-03T07:57:05Z Indexed on 2010/06/03 8:24 UTC
Read the original article Hit count: 185

Filed under:

I have a class

Class TextChunks extends Token {
    ArrayList<Token> arrt = new ArrayList<Token>();
}

extent fron class :

class Token {
    String s;
    int frequency = 1 ;// Tern frequency in TextChunk
    }

Now in token i have arraylist token , i want to update attribute frequency of token in Texchunks when have more than one tokens same .

For clearly a give a example :

Texchunks :" in particular in domain and range in some "

So have 8 token : in,particular,in,domain,and,range,in,some

i want update attribute frequency for token : in this example when i get attribute frequency of token "in" must return 3

it mean when i call : get frequency of Texchunks when dislay :

in 3
particular 1
in 3
domain 1 
and 1
range 1
in 3
some 1

here my code :

public TextChunks updateFrequencyOfTokenInTextChunks (TextChunks tc) throws CloneNotSupportedException {
        TextChunks result = (TextChunks) tc.clone();

        for (int i =0 ; i< result.arrt.size() ; i++ ){
            int j=i+1;
            if (result.arrt.get(i).compareTwoToken(result.arrt.get(j))== true )
            {
                // help here how to update attribute result.arrt.get(i) 
                            // and result.arrt.get(J) = ++ and 
            }

        }
        return tc;

    }

Thanks in advandce

© Stack Overflow or respective owner

Related posts about java