Results 1 to 4 of 4
  1. #1
    jessie is offline Member
    Join Date
    Nov 2010
    Posts
    29
    Rep Power
    0

    Default replacing patterns in text

    Hi,

    Im resolving conferencing named entities in text. i want to replace all the entities referring to the same name into one single name. for example i have a list of words like,

    Winston Kennedy
    Mr.Kennedy
    Kennedy
    Winston E.Kennedy
    which refer to the same person. in my text i want to replace the words, Mr.Kennedy, Kennedy and Winston E.Kennedy with Winston Kennedy . but the problem is when i use regex patterns, the word Kennedy is replaced also in the word Winston Kennedy and returns Winston Winston Kennedy. it also happens in Winston E.Kennedy and returns Winston E.Winston Kennedy.

    how can i solve this?

  2. #2
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Smile

    Use regular expressions functionality of java.
    Matcher and Pattern classes of java.util.regex package are to be used for this.

    Try using them and come back if still stuck.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by jessie View Post
    Hi,

    Im resolving conferencing named entities in text. i want to replace all the entities referring to the same name into one single name. for example i have a list of words like,

    Winston Kennedy
    Mr.Kennedy
    Kennedy
    Winston E.Kennedy
    which refer to the same person. in my text i want to replace the words, Mr.Kennedy, Kennedy and Winston E.Kennedy with Winston Kennedy . but the problem is when i use regex patterns, the word Kennedy is replaced also in the word Winston Kennedy and returns Winston Winston Kennedy. it also happens in Winston E.Kennedy and returns Winston E.Winston Kennedy.

    how can i solve this?
    Do it in several steps; in each step replace one of the name variants to a canonical form, say, "XXXXX"; after the last step has been done your String contains a number of "XXXXX" instances; replace all of them by the single name variant you want.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    jessie is offline Member
    Join Date
    Nov 2010
    Posts
    29
    Rep Power
    0

Similar Threads

  1. finding regex patterns in text file
    By jessie in forum New To Java
    Replies: 4
    Last Post: 11-08-2010, 09:42 PM
  2. Replies: 0
    Last Post: 08-18-2010, 11:31 AM
  3. replacing text in jTextArea by image
    By Pain in forum AWT / Swing
    Replies: 2
    Last Post: 03-06-2010, 06:59 PM
  4. Patterns
    By whosadork in forum New To Java
    Replies: 8
    Last Post: 10-23-2008, 12:37 PM
  5. Bean Patterns
    By Sysem in forum New To Java
    Replies: 0
    Last Post: 05-26-2008, 08:33 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
  •