Page 1 of 1

10584 - Text Formalization

Posted: Thu Mar 11, 2004 2:06 am
by windows2k
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 :D

Posted: Thu Mar 11, 2004 7:28 am
by Andrey Mokhov
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.

Hope this will help you.
Have AC. :)
Andrey.

Posted: Thu Mar 11, 2004 8:05 am
by windows2k
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?
Thx your reply :D

Posted: Thu Mar 11, 2004 8:42 am
by Andrey Mokhov
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 :roll:
But I try :P

Bye.
Andrey.

Posted: Mon Jun 07, 2004 10:15 am
by little joey
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"
".." -> "."
"EL" -> "European License"
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."

Posted: Tue Jul 20, 2004 6:31 am
by wyvmak
Thanks for your smart hint. And I have to throw away my common sense and common interpretation on english words again.