×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    35

    Problem with Database and StringTokenizer in J2ME?

    Hello, good evening.

    I used StringTokenizer in my "SMS Textspeak Corrector". This application has a database "db.txt" as I mentioned in my other topics.

    This is the database what it looks like if you try to open my database:
    u|you|wer|where|wen|when|dat|that|u?|you?|wer?|where?|wen?|when?|dat?|that?|
    As you can see in my database, there is a "|" in the middle of two words. Which means "u" is a textspeak and the "you" is the original word and the bar their is the delimiter. As you can see as well, I just copied the words and just putted a question mark. Because in the SMS there's a period, question, and exclamation marks on every end of the sentence. And the StringTokenizer will read the word (along with the question mark) as a whole word. If the program found a match in the database it will replace the textspeak to its original word. Hope you guys got it. Just tell if you didn't get it.

    What I want is to erase the "u?|you?|wer?|where?|wen?|when?|dat?|that?|"

    and retain the "u|you|wer|where|wen|when|dat|that|" so that the database won't be so heavy.

    But the problem is those words that ends with period, question, and exclamation marks will not be replace.

    So how will I solve this problem?

    Here's the code of my StringTokenizer:
    Code:
                  data = file();
                  text = message.getString();
                  StringTokenizer stText = new StringTokenizer(text," ");
                  while(stText.hasMoreTokens())
                  {
                      int found = 0;
                      readWord = stText.nextToken();
                      StringTokenizer st = new StringTokenizer(data,"|");
                      while ((st.hasMoreTokens()) && (found==0))
                      {
                          txtspkWord = st.nextToken();
                          realWord = st.nextToken();
                          if(txtspkWord.equalsIgnoreCase(readWord))
                          {
                              found = 1;
                          }
                      }
                      if(found==1)
                      {
                          newtxt = newtxt + "" + realWord + " ";
                      }
                      else
                      {
                          newtxt = newtxt + "" + readWord + " ";
                      }
                  }
                  temp = newtxt;
                  newtxt = "";
                  capital = capitalize(temp);
                  message = new TextBox ("Message", capital, 2000,TextField.ANY);
                  message.addCommand(ok);
                  message.addCommand(clear);
                  message.addCommand(exit);
                  message.setCommandListener(this);
    Last edited by SHENGTON; 2011-02-11 at 16:28.

  2. #2
    Registered User
    Join Date
    Feb 2011
    Posts
    35

    Re: Problem with Database and StringTokenizer in J2ME?

    Hello,

    Anyone could help?

Similar Threads

  1. how to solve this problem?
    By patel_rakesh95 in forum [Archived] Qt Mobility Project
    Replies: 1
    Last Post: 2010-10-06, 12:40
  2. How to solve this problem?
    By sundy10 in forum Symbian
    Replies: 4
    Last Post: 2009-10-20, 19:33
  3. how to solve this problem?.......
    By bharats in forum Symbian
    Replies: 23
    Last Post: 2006-12-11, 10:23
  4. How can I solve this problem?
    By hydlx in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2006-08-02, 07:24
  5. How to solve this math in MIDP1.0?
    By agajewski in forum Mobile Java General
    Replies: 5
    Last Post: 2005-02-11, 13:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •