I have a set of sentences i need to use to do a replace, for example:
abc => cde
ab df => de
...
And i have a text where to make the changes. However i have no way to know beforehand case of said text. So, for example, if i have:
A bgt abc hyi. Abc Ab df h
I must replace and get:
A bgt cde nyi. Cde De h
Or as close to that as possible, i.e. keep case
EDIT: As i am seeing to much confusion about this i will try to clarify a bit:
I am asking about a way to keep caps after replacing and i don't think that passed through well (not well explained what thaat entails) so i will give a more realistic example using real words.
think of it like a gossary, replacing expressions by their sinonyms so to speak, so if i map:
didn't achieve success => failled miserably
then the i get as input the setence:
As he didn't achieve success, he was fired
i would get
As he failled miserably, he was fired
but if didn't was capitalized, so would failled, if achieve or success was capitalized, so would miserably, if any had more than 1 letter capitalized, so would it's counterpart
My main possibilities are (ones i really want to take into cosideration)
- only first letter of first word capitalized
- only first letter of every word capitalized
- all letters capitalized
If i can handle those three that would be acceaptable already i guess - it's the easyer ones - of course a more in depth solution would be better if availlable
Any ideas?