algorithm - Some kind of grammar parsing but without brute force -


i have list of "transformations"/"grammar" whatever can call of form:

l -> l|ll|n

this means l(letter) can transformed in either 1 letter or 2 letters or in 1 n(number)

i'm given list of transformations , sequence of numbers , initial move performed , have generate minimum list of moves generate sequence of numbers given.

for example:  have transformations a->bc b->d b->ed c->f c->fb d->2 d->3 e->0 e->1 f->4  sequence: 2 4 0 3 initial move performed:  minimum list be:  1.(a, bc) [bc](initial move) 2.(b, d) [dc] 3.(d, 2) [2c] 4.(c, fb) [2fb] 5.(f, 4) [24b] 6.(b, ed) [24ed] 7.(e, 0) [240d] 8.(d, 3) [2403]  

there no loops example a->ab or a->b , b->a etc brute force not option since input of transformation big ~1000 , sequence generate ~30.

after extensive search on internet found cyk algorithm after aplying on example results sequence 2403 not in grammar(which wrong).

i don't see how should proceed trying days solve this. welcome. thank you.

before can apply cyk, grammar must in chomsky normal form, means need eliminate unit rules.

in other words, rule b->d must converted 2 rules: b->2 , b->3. likewise, rule c->f must converted c->4.

once you've made adjustments grammar, in chomsky normal form, cyk work. of course, when displaying parser results, time invoke 1 of converted rules, you'll need generate 2 lines of output. example, invocation of b->2 should displayed b->d followed d->2.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -