Regex: Up for a challenge?

B

basi

Hello,
Just having an outstandingly hard time to even come close to being able
to translate the following string sequences in one or a series of
regular expressions. These are allowable prefix combinations in a
language I'm doing some text analysis on.

i pa(ki) pag
ma i ka pa(ki) pag
ma pa ka
ma(ki) pag ka
man
m(an) ag ka sin
m(an) ag kan(da)
m(an) ag si(pag)
m(an) ag pa

The first one allows the following choices:
i, pa, pag, ipa, ipag, ipapag, papag, ipaki, ipakipag, paki, pakipag

The syllable inside parentheses can only be selected if the syllable or
letter it is attached to is selected.

Just something to take our minds away from Eckel-ysteria.

Thanks again,
basi
 
R

Rich Morin

My first cut at the problem would be to

* write a generator that translates string sequences

i pa(ki) pag

into persistent lists of prefixes

i, pa, pag, ipa, ipag, ...

* write a method that uses these prefixes,
as is: /^i/, /^pa/, ...

As Ken Thompson said, "When in doubt, use brute force".


Once this worked, I'd check to see if it was "fast enough".
If not, I'd look into reworking the methods. The important
issues are (a) getting something working quickly and (b)
keeping the implementation details hidden. If speed is a
real issue, you may need to go to a fairly fancy solution,
so don't tie yourself to regexes!

-r
 
B

basi

Hi,
Speed is not an issue at this point. As you say, just get it working
for now. What would be a "fancy" solution?

Right now, my solution is bruter than brute force: Take the first 9
syllables (prefixes can pile up to syllables deep, which include
reduplicated syllables and an infix somewhere there. The data in my OP
does not indicate these, but reduplications and infixation are easy to
wedge into the solution). Match it with the prefix list. If no match,
take the first 8 syllables, and so forth. Shameless.

Thanks!
basi
 
B

basi

Hi,
Thanks for your suggestion. I'm checking it right now for under/over
generation!
basi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top