10584 - Text Formalization

Moderator: Board moderators

windows2k
Experienced poster
Posts: 136
Joined: Sat Apr 05, 2003 3:29 pm
Location: Taiwan

10584 - Text Formalization

I tried to solve the problem.
Thought it is a simple text processing problem.
But get WA all the time.
Would someone give some input/output? Thx

Andrey Mokhov
Experienced poster
Posts: 128
Joined: Fri Nov 15, 2002 7:45 am
Location: Kyrgyzstan
Hello!

I've recently solved the problem and I also got WA the first time. I think there are two possible mistakes:

1. Suppose, you have a contraction "AB" -> "A and B" and you meet in text string AB. According to the problem statement you should output "A and B" - not "A AND B". Note, that if the contraction were "Ab" -> "A and B" than you would print "A AND B", however.

2. If you have two contractions "AB C"->"A B and C" and "AB"->"A and B" and analize string AB C D ... you shouldn't stop when you found match AB - you are to continue comparing because you will meet AB C which should be replaced as its contraction appear earlier in the input.

Have AC.
Andrey.

windows2k
Experienced poster
Posts: 136
Joined: Sat Apr 05, 2003 3:29 pm
Location: Taiwan
Sorry , I don't understand your meanning clearly.
Andrey Mokhov wrote: 1. Suppose, you have a contraction "AB" -> "A and B" and you meet in text string AB. According to the problem statement you should output "A and B" - not "A AND B". Note, that if the contraction were "Ab" -> "A and B" than you would print "A AND B", however.
According the problem, Each contraction may appear as listed, entirely uppercase, or capitalized (first letter uppercase, remaining letters as listed). The expansion should follow the same rule; if a contraction is uppercased, the expansion should be uppercased as well.
If I have a contraction "AB" -> " A and B"
when I input ab , I should output "a and b"?
AB, I should output "A AND B"?
Ab,, I should output "A and b"?
maybe I misunderstand the problem.
2. If you have two contractions "AB C"->"A B and C" and "AB"->"A and B" and analize string AB C D ... you shouldn't stop when you found match AB - you are to continue comparing because you will meet AB C which should be replaced as its contraction appear earlier in the input.
Andrey.
If more than one case applies, choose the earliest matching case in the list: "as listed," "uppercased," and "capitalized."
now we have two contractions.
1. "AB C" -> "A B and C"
2. "AB" ->"A and B"
iwhen I input AB C D, I search from 1 to C.
if some contraction matched , I used the rule?
Am I right?

Andrey Mokhov
Experienced poster
Posts: 128
Joined: Fri Nov 15, 2002 7:45 am
Location: Kyrgyzstan
Hi!
windows2k wrote:Each contraction may appear as listed, entirely uppercase, or capitalized (first letter uppercase, remaining letters as listed). The expansion should follow the same rule; if a contraction is uppercased, the expansion should be uppercased as well.
The problem is that sometimes you can't say if it is as listed, uppercased or capitalized! Can you say AB is uppercased or as listed if it was AB at start? So as problem statement says in such case you should consider it to be written as listed:
If more than one case applies, choose the earliest matching case in the list: "as listed," "uppercased," and "capitalized."
And now
windows2k wrote:If I have a contraction "AB" -> " A and B"
when I input ab , I should output "a and b"?
AB, I should output "A AND B"?
Ab,, I should output "A and b"?
No, all three cases are incorrect!

1) ab doesn't match the contraction.
2) AB should be A and B (as listed) - not A AND B (uppercased)
3) Ab doesn't match the contraction either.

And about my second point from my previous topic - I just meant that your program shouldn't stop search as soon as you find some match because there may be longer match beginning with the same prefix.

Yeah... hard to explain in foreign language
But I try

Bye.
Andrey.

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm
As I learned after getting a few WAs, don't try to be smart!

The input

Code: Select all

2 1
"it's" -> "it is"
".." -> "."
HELLO! It's obvious that Babbit's EL is expired......
#
Transforms to

Code: Select all

HEuropean License (EL)LO! It is obvious that Babbit is EL is expired...
#
And not to the more sensible "HELLO! It is obvious that Babbit's European License (EL) is expired."

wyvmak
Experienced poster
Posts: 110
Joined: Thu Dec 13, 2001 2:00 am
Thanks for your smart hint. And I have to throw away my common sense and common interpretation on english words again.