469,612 Members | 1,621 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

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.FindMatchingWord();
if (MatchingWord != "")
{
word = MatchingWord; //How to take care of the upper or
lower case of each letter here?

}

}

Any advice? Thanks!

Aug 17 '07 #1
1 2264
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)
http://www.johntimney.com
http://www.johntimney.com/blog
"Curious" <fi********@yahoo.comwrote in message
news:11**********************@r29g2000hsg.googlegr oups.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.FindMatchingWord();
if (MatchingWord != "")
{
word = MatchingWord; //How to take care of the upper or
lower case of each letter here?

}

}

Any advice? Thanks!

Aug 18 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Thomas Philips | last post: by
4 posts views Thread by Werner Merkl | last post: by
3 posts views Thread by Claude Schneegans | last post: by
8 posts views Thread by DrNoose | last post: by
17 posts views Thread by Janice | last post: by
18 posts views Thread by Jon S via DotNetMonster.com | last post: by
19 posts views Thread by Eric Lindsay | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.