|How do I get the rules' ranks in semantic actions?||rns||9/7/12 9:48 PM|
This is needed for .
I can get the rule IDs and names and the grammar  but not the rank .
Am I missing something?
Thanks in advance.
The most general way to sort Marpa parses is for the application to take control. The application can set up the Marpa semantic actions so that the parse result of every parse tree is a
|Re: How do I get the rules' ranks in semantic actions?||Jeffrey Kegler||9/7/12 10:02 PM|
What I was trying to say in the quoted portion is that *you* must compute the rank as part of the parse value. So the parse value might, for example, be a pointer to an array whose first element is rank, and whose second element is what would otherwise be the returned value. You then collect all these and sort them. In other words, in the most fully general ranking method, the application basically does almost all the work itself.
The ranking methods currently implemented within Marpa were the result of a lot of experimentation. The ones Marpa implements directly are only those where Marpa's evaluator can clearly "add value", in the form of efficiency. This means they are fairly simple and require only the kind of local knowledge that the evaluator can efficiently act upon. If you are ranking, say, parses of English sentences, you could easily get into the kind of complexity where you may simply have to dump all possible parses from Marpa, and after the Marpa run is complete, compute the rank and sort them.
I hope this clarifies/helps,
|Re: How do I get the rules' ranks in semantic actions?||rns||9/7/12 10:12 PM|
I hope this clarifies/helps,
Yes it does. Thanks a lot for the quick reply.
Then the true_value in "
And the two orthogonal approaches to ranking when using Marpa are (1) assigning ranks to rules in the grammar and letting Marpa do the sorting/rejection ("rule" and "high_rule_only") and (2) assigning ranks to rules in the actions and sorting the parse trees by traversing them in the application?
|Re: How do I get the rules' ranks in semantic actions?||Jeffrey Kegler||9/7/12 10:21 PM|
If the parse values in your application are trees then, yes, true_value would be a parse tree. (In a calculator, for example, the parse value might be an integer.) It may also be the case that it's more convenient to just return the tree and figure out its rank afterwards.
The two ranking approaches aren't necessarily orthogonal. Again, take the example of ranking parses of English sentences. You might be able to craft a strategy where you use "rule" ranking to get an approximation, and only generate (for example) the top 6 parses. These you subject to a more expensive ranking algorithm and the winner of the second ranking becomes the parse.
|Re: How do I get the rules' ranks in semantic actions?||rns||9/7/12 11:05 PM|
On Saturday, September 8, 2012 8:21:38 AM UTC+3, Jeffrey Kegler wrote:
Sure, thanks for the explanation.
What I was trying to say by "orthogonal" is that the application can't see the ranks set in the grammar and the grammar can't see the ranks set by the application (well it can, if they are put in the scratch pad (action sub's first arg) but doesn't and doesn't need to).
This feels like the right thing, but coming from Perl culture (TIMTOWTDI), I can't help thinking that in general the semantic actions might need to know (and perhaps to even modify) the rule's ranks set in the grammar. I can't come up with a proper use case at the moment though.
Thanks a lot for the great clarifications!