Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: SMS Textspeak Corrector

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclamation SMS Textspeak Corrector

    Hello

    This is a thesis. My thesis is "SMS Textspeak Corrector". SMS Textspeak Corrector is a text messaging software for mobile phone where users can convert or correct the “txt spk” message to the original normal words. For instance, it will correct the “txt spk” text message to “text speak” when a user send the message to the recipient. So the recipient will receive the complete words of text message in his mobile phone.

    Now, my problem is the correcting part. I don't know where to start since I'm newbie with this language.

    Can somebody help me.

    Thanks.


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: SMS Textspeak Corrector

    Hello SHENGTON,

    Welcome to the Java Programming Forums.

    I don't have any experience in JavaME but in JaveSE you could use the String replaceAll method for correcting - String (Java Platform SE 6)
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  3. The Following User Says Thank You to JavaPF For This Useful Post:

    SHENGTON (January 13th, 2011)

  4. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: SMS Textspeak Corrector

    Here is an example for you. It's not perfect but you get the idea. Obviousally it needs to be adapted for JavaME.

     
    	public static String[] txtWord = {"txt","spk","lol","np","brb"};
    	public static String[] realWord = {"text","speak","laugh out loud","no problem","be right back"};		
     
    	public static void main(String[] args) {
     
    		String phrase = "Hello mate. Long time no spk, lol. Thats np, i'll brb!";
     
    		for(int a = 0; a < txtWord.length; a++){
     
    			if(phrase.contains(txtWord[a])){
    				phrase = phrase.replaceAll(txtWord[a], realWord[a]);
    			}
    		}
     
    		System.out.println(phrase);
    	}

    Input:

    Hello mate. Long time no spk, lol. Thats np, i'll brb!

    Output:

    Hello mate. Long time no speak, laugh out loud. Thats no problem, i'll be right back!
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  5. The Following User Says Thank You to JavaPF For This Useful Post:

    SHENGTON (January 13th, 2011)

  6. #4
    Junior Member
    Join Date
    Jan 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: SMS Textspeak Corrector

    Hello JavaPF, good afternoon.

    Thanks for taking time replying my problem. Thanks for the codes, it gives me an idea how to figure it out. I'll try that later but for now I'm trying to solve how to create submenu in J2ME. I tried to Google it but none of the links gives me an answer.

    By they way, I'm using a Motorola cellphone for testing purposes.

    Thanks .

  7. #5
    Junior Member
    Join Date
    Jan 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: SMS Textspeak Corrector

    Hello JavaPF, good evening.

    Please take a look my code. I having a problem in replacing the text inside the TextBox.

    Here's the code:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.TextBox;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Command;
     
    public class TextBoxMIDlet extends MIDlet implements CommandListener
    {
      private Display display;
      private static String[] txtWord = {"txt","spk","lol","np","brb"};
      private static String[] realWord = {"text","speak","laugh out loud","no problem","be right back"};
      private Command txtspk = new Command("Correct Textspeak", Command.ITEM, 0);
      private Command exit = new Command("Exit", Command.EXIT, 0);
      private TextBox t;
     
      public TextBoxMIDlet() {
        display = Display.getDisplay(this);
      }
     
      public void startApp() {
          t = new TextBox ("TextBox Example", null, 256, TextField.ANY);
          t.addCommand(txtspk);
          t.addCommand(exit);
          t.setCommandListener(this);
          display.setCurrent(t);
      }
     
      public void pauseApp() {}
     
      public void destroyApp(boolean unconditional){}
     
      public void commandAction(Command command, Displayable displayable)
      {
          if (command == exit)
          {
              destroyApp(true);
              notifyDestroyed();
          }
          if (command == txtspk)
          {
              for(int a = 0; a < txtWord.length; a++)
              {
                  if(t.equals(txtWord[a]))
                  {
                      t = t.replaceAll(txtWord[a], realWord[a]);
                  }
              }
              System.out.println(t);
          }
      }
    }

    I'm having a problem with this this part:
          if (command == txtspk)
          {
              for(int a = 0; a < txtWord.length; a++)
              {
                  if(t.equals(txtWord[a]))
                  {
                      t = t.replaceAll(txtWord[a], realWord[a]);
                  }
              }
              System.out.println(t);
          }

    I don't know how to figure it out. What's wrong with my code?
    Last edited by SHENGTON; January 17th, 2011 at 07:03 AM.