Replace words with proper upper/lower cases

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Curious

    #1

    Replace words with proper upper/lower cases

    I'm working on a word replacement program in .NET. I have a list of
    words spelt in American English and need to replace them with
    translated British spelling while keeping the upper or lower cases of
    each letter in these words.

    For instance, I have a dictionary below:

    theater theatre
    center centre
    annualized annualised

    Then I want to replace the applicable words in the dictionary in
    American English with equivalent British words:

    "I went to the CAPITAL THEATER on Center Street to see a show this
    past weekend."

    The result should be:

    "I went to the CAPITAL THEATRE on Centre Street to see a show this
    past weekend."

    I have a loop through each word, and see if the word is in any of the
    American words the the dictionary (by case-insensitive comparison),
    but the challeging part is to replace the word with the equivalent
    British word while keeping the original upper or lower case of each
    letter in the word.

    foreach (word in article)
    {
    MatchingWord = word.FindMatchi ngWord();
    if (MatchingWord != "")
    {
    word = MatchingWord; //How to take care of the upper or
    lower case of each letter here?

    }

    }

    Any advice? Thanks!

  • John Timney \(MVP\)

    #2
    Re: Replace words with proper upper/lower cases

    Pretty much an impossible task, because the same words don't have the same
    letter counts even.......take colour as an example...or is it color? Check,
    or is it cheque? What do you plan to do with letters that don't actually
    exist in your source word?

    Regards

    John Timney (MVP)




    "Curious" <fir5tsight@yah oo.comwrote in message
    news:1187362163 .587603.277980@ r29g2000hsg.goo glegroups.com.. .
    I'm working on a word replacement program in .NET. I have a list of
    words spelt in American English and need to replace them with
    translated British spelling while keeping the upper or lower cases of
    each letter in these words.
    >
    For instance, I have a dictionary below:
    >
    theater theatre
    center centre
    annualized annualised
    >
    Then I want to replace the applicable words in the dictionary in
    American English with equivalent British words:
    >
    "I went to the CAPITAL THEATER on Center Street to see a show this
    past weekend."
    >
    The result should be:
    >
    "I went to the CAPITAL THEATRE on Centre Street to see a show this
    past weekend."
    >
    I have a loop through each word, and see if the word is in any of the
    American words the the dictionary (by case-insensitive comparison),
    but the challeging part is to replace the word with the equivalent
    British word while keeping the original upper or lower case of each
    letter in the word.
    >
    foreach (word in article)
    {
    MatchingWord = word.FindMatchi ngWord();
    if (MatchingWord != "")
    {
    word = MatchingWord; //How to take care of the upper or
    lower case of each letter here?
    >
    }
    >
    }
    >
    Any advice? Thanks!
    >

    Comment

    Working...