[REBOL] Re: [REBOL parse] Parsing AEIOU and sometimes Y
From: lmecir:mbox:vol:cz at: 2-May-2007 23:01
Ed O'Connor napsal(a):
> Hi Ladislav--
>
> On 5/2/07, Ladislav Mecir wrote:
>
>> you can forget about the "sometimes" y when using my suggestion:
>>
>
> I'd be delighted to forget about that! I sure am glad there aren't
> other special rules, such as "i before e, except after c."
>
>> parse "banana" rule
>> the trouble is, that your pair counting rule still doesn't look exact
>>
>
> Hmmm... it appears to generate correct results... here is the relevant
> passage from the research paper:
>
> "[C]VCVC ... [V]
>
> where the square brackets denote arbitrary presence of their contents.
> Using (VC){m} to denote VC repeated m times, this may again be written
> as
>
> [C](VC){m}[V].
>
> m will be called the measure of any word or word part when represented in
> this form. The case m=0 covers the null word. Here are some examples:
>
> m=0 TR, EE, TREE, Y, BY.
> m=1 TROUBLE, OATS, TREES, IVY.
> m=2 TROUBLES, PRIVATE, OATEN, ORRERY."
>
> The rule you've written returns the correct m for these words, as well
> as anything I've thrown at it so far.
>
> Thanks
>
aha, sorry, I thought that "tree" was supposed to yield m = 1. Here is
an optimized version:
vowel-after-consonant: charset "aeiouAEIOU"
vowel-otherwise: charset "aeiouyAEIOUY"
consonant-after-consonant: exclude charset [
#"a" - #"z" #"A" - #"Z"
] vowel-otherwise
consonant-otherwise: union consonant-after-consonant charset "yY"
after-consonant: first [
(
vowel: [vowel-after-consonant otherwise]
consonant: [consonant-after-consonant after-consonant]
)
]
otherwise: first [
(
vowel: [vowel-otherwise otherwise]
consonant: [consonant-otherwise after-consonant]
)
]
rule: [
(m: 0)
otherwise
any consonant
any [some vowel some consonant (m: m + 1)]
any vowel
]
-L