Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 834751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:43:17+00:00 2026-05-15T04:43:17+00:00

I have a class Class TextChunks extends Token { ArrayList<Token> arrt = new ArrayList<Token>();

  • 0

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;
        
    }

Here is method compare two token

    public boolean compareTwoToken(Token tk){
    if(this.s.toLowerCase().trim().equals(tk.s.toLowerCase()))
        return true;
    return false;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:43:18+00:00Added an answer on May 15, 2026 at 4:43 am

    Your incomplete algorithm doesn’t work because j doesn’t find in previous position of i.
    A posible solution could be:

    • updateFrequencyOfTokenInTextChunks method:

      public static void updateFrequencyOfTokenInTextChunks (TextChunks tc) {
        Hashtable<String,Integer> visited = new Hashtable<String,Integer>();
      
        for (Token token : tc.arrt){
          if (visited.containsKey(token.s)) {
              token.frequency = visited.get(token.s);
          } else {
              int n = count(token, tc);
              visited.put(token.s, n);
              token.frequency = n;
          }
        }
      }
      

    My solution doesn’t return any type, because I understand the update (updateFrequencyOfTokenInTextChunks) should modify the parameter (TextChunks tc) and no return a clone.

    • count auxiliar method:

      private static int count(Token t, TextChunks tc) {
        int cont = 0;
        for (Token token : tc.arrt) {
            if ( t.compareTwoToken(token) ) {
                cont++;
            }
        }
        return cont;
      }
      

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class that extends BroadcastReceiver and gets all new sms. When I get
I have: class first{ private: int *array; public: first(int x){ array = new int[x][10];
I have class with back reference: public class Employee : Entity { private string
I have class with collection as below public class MyClass:IXmlSerializable { int vesrion; private
I have class Meat extends Food { $var = Food::foodFunction… } I need to
I have :- Class Abc extends Activity(){ private ActivityManager am; private List<RunningAppProcessInfo> rList; @Override
I have class Person: public class Person : INotifyPropertyChanged { private String name =
I have a class which outputs a lot of textchunks, depending on an initial
I have Class which Extends View I'm able To Move one Image Over another
I have class class User extends BaseModel{ public $id; public $name; } class BaseModel{

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.