Results 1 to 11 of 11
  1. #1
    conv_bay is offline Member
    Join Date
    Apr 2009
    Posts
    15
    Rep Power
    0

    Question COMBINATION TEXT..help me..urgent

    i using stringtokenizer to separate be a word..
    after that im using dat word to search their meaning..

    n now i want to combine all the word..
    how 2 do??

    im doing machine translation..
    dat y im using string tokenizer to separate the input.
    :confused:
    :(

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    830
    Rep Power
    6

    Default

    Hi,
    For understanding clearly,Can u please give me an example string and what ooutput d u want?

  3. #3
    corlettk is offline Member
    Join Date
    Apr 2009
    Location
    Brisbane
    Posts
    86
    Rep Power
    0

    Default It seems I'm destined to be surround by dills.

    Quote Originally Posted by conv_bay View Post
    i using stringtokenizer to separate be a word..
    StringTokeniser is basically deprecated... Don't use it. Try String.split or Pattern/Matcher instead.

    Loose the SMS-speak. It's illegible, and it s**ts me besides. You've got a complete working keyboard. Use it.

  4. #4
    conv_bay is offline Member
    Join Date
    Apr 2009
    Posts
    15
    Rep Power
    0

    Unhappy description my work..

    i dont know how 2 describe..

    i do machine translate..
    after user input the sentence,
    it will separate to word by word cz i relate to database.
    it easy for my machine to search the meaning about the words..

    example :

    user input : saya suka makan
    machine output : saya = i
    suka = like
    makan = eat

    n now i want to combine dat word be a 1 sentences..
    example :

    machine output : i like eat..

    how can i combine dat word after machine search their meaning in database??:confused::mad:

  5. #5
    conv_bay is offline Member
    Join Date
    Apr 2009
    Posts
    15
    Rep Power
    0

    Default

    anyone plz help me..

  6. #6
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default

    Take a look at the StringBuilder, it will let you put your tokens back into a String.

  7. #7
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Quote Originally Posted by conv_bay View Post
    anyone plz help me..
    Hi conv_bay, I've just come across the message you left in another thread soliciting help and there's a few helpful things I can think of:

    (0) Don't do that. That is, don't post on someone else's thread saying "help me". It's just rude.

    (1) Think of a meaningful title for your question. It could be "Splitting and combining words in a String". Don't tell people in your title or elsewhere that they should regard your question with urgency. They are free to do whatever they like.

    (2) Don't use "dis sms krap 2 ask ur q". No-one is going to worry about your English (many native English speakers are hoplessly ignorant of other languages and will recognise and admire your efforts) but speaking "lik dis" is a major turn off.

    (3) Don't just ignore suggestions. If you don't understand or disagree for some reason, post back. If the suggestions work, post back to say that.

    Sorry about all the "don'ts", but help's like that sometimes.

    I think the suggestions you've had so far
    • use String.split instead of StringTokenizer
    • use StringBuilder or StringBuffer to combine the results

    pretty much answers your question. But post back if you're still having problems. (With your code would be good.)
    Last edited by pbrockway2; 04-25-2009 at 03:24 AM.

  8. #8
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    830
    Rep Power
    6

    Default

    Please go thrus this code sample whether it helps you .
    import java.util.*;
    public class Sample
    {
    /*I have stored the string which iam going to tokenize and its corresponding value in hastable.
    After splitting the string and retreiving the corresponding value from the Hashtable.*/
    public static void main(String args[])
    {
    String inputString = "saya suka makan";
    StringTokenizer st = new StringTokenizer(inputString);
    Hashtable ht = new Hashtable();

    ht.put("saya","i");
    ht.put("suka","like");
    ht.put("makan","eat");
    String finalString ="";
    while(st.hasMoreTokens())
    {
    finalString = finalString + ht.get(st.nextToken().trim())+" ";
    }//while
    System.out.println(finalString);
    }//main
    }//Sample

  9. #9
    MuslimCoder is offline Senior Member
    Join Date
    Jan 2009
    Posts
    119
    Rep Power
    0

    Default

    You can try using a "String.concat()" method...e.g.
    Java Code:
    String word = "Terih";
    word = String.concat("Makasih");
    
    System.out.println(word);
    Result should be:
    Terih Makasih

  10. #10
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    In the effort to explain herself Alice had quite lost her voice. But her gaze was led to a glass of split() and StringBuilder flavoured water bearing the legend "Drink Me". "Don't do it," advised the caterpillar, "They can't make you." And handed her the hookah.

  11. #11
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You forgot to mention: "Twas brillag and the slithy toves did gyre and gimble in the wabe;"

Similar Threads

  1. I need Help Urgent..
    By vidhyaprakash85 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 02-18-2009, 06:49 AM
  2. Replies: 2
    Last Post: 01-23-2009, 04:09 PM
  3. printing simple text as text on printer
    By Nicholas Jordan in forum Advanced Java
    Replies: 0
    Last Post: 12-01-2008, 01:42 AM
  4. find and replace text from a text file
    By gezzel in forum New To Java
    Replies: 2
    Last Post: 09-19-2008, 04:04 PM
  5. Replies: 0
    Last Post: 05-26-2008, 04:26 PM

Posting Permissions

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