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 2 of 2

Thread: How to hyphanate phrase which is present in database

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to hyphanate phrase which is present in database

    I want to hyphenate a token which is present in a database. My code:

    String str = "The Appointments Committee Cabinet has approved the appointment of Dr. Harry Potter, Chief Economic Adviser, Department of Economic Affairs as Executive Director in the International Monetary Fund.";
    String[] words = str.split(" ");
    LinkedList<String> linkedlist=new LinkedList<String>();
    for (int i = 0; i <= words.length-1; i++) {
    linkedlist.add(words[i]);
    }
    ListIterator itr = linkedlist.listIterator();
    Connection con = null;
    PreparedStatement pstTemp = null;
    StringBuilder tokens = new StringBuilder();
    try {
    con = DBConnection.getJndiConnection();
    StringBuffer sbQry = new StringBuffer("SELECT englishlex FROM lex_hindi where (domain='Tourism' or domain='Zgeneral') and englishlex=");

    while (itr.hasNext()) {
    System.out.println(itr.next());

    tokens.append(itr.next());
    sbQry.append("'"+tokens+ "',");
    System.out.println(tokens.toString());


    }

    sbQry.append(" order by length(englishlex) desc");
    tokens.setLength(0);

    } catch (SQLException ex) {
    Logger.getLogger(PhraseMarker.class.getName()).log (Level.SEVERE, null, ex);
    }
    I want to implement this algorithm, I will start with "The Appointments", whether it is present in table or not. If yes, then move forward and check for the next token- whether entry for "The Appointments Committee" is present. If yes, then again move forward, and check for "The Appointments Committee Cabinet". If entry is present, then again move forward, if not, then move back, then hyphenate "The-Appointments-Committee". Then again start with "Cabinet"- the same process all over again. I want to use a select query- it should give a smaller result set, so the speed should be much faster.please suggest changes in my code


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: How to hyphanate phrase which is present in database

    Please don't post multiple threads on the same topic.

Similar Threads

  1. Replies: 7
    Last Post: February 10th, 2014, 09:45 AM
  2. logic present tag
    By naval.gupta4u@gmail.com in forum Java Servlet
    Replies: 0
    Last Post: July 15th, 2012, 01:28 AM
  3. [SOLVED] Replace Phrase in String
    By aussiemcgr in forum Java Theory & Questions
    Replies: 2
    Last Post: October 18th, 2010, 12:10 PM

Tags for this Thread