grammar = (FirstName, OPTIONAL(MiddleName), OPTIONAL(LastName)) | (LastName, LITERAL(","), FirstName)
I get an error: TypeError: unsupported operand type(s) for |: 'tuple' and 'tuple'
However, separately, they work -
grammar1 = (FirstName, OPTIONAL(MiddleName), OPTIONAL(LastName))
grammar2 = (LastName, LITERAL(","), FirstName)
How would one combine multiple sub-grammars? Also, if I want to implement probabilistic context free grammar (PCFG), where each of these sub-grammars has a weight (from 0 to 1), how could I specify that?
Thanks!
(GrammarOne, GrammarTwo, GrammarThree)
GRAMMAR(GrammarOne, GrammarTwo, GrammarThree)
GrammarOne | GrammarTwo # Grammar OR Grammar --> Grammar(GrammarOne, GrammarTwo) | GrammarThree # tuple OR Grammar (automatically convert the tuple to a Grammar) --> GrammarGrammarOne | (GrammarTwo, GrammarThree) # Grammar OR tuple (automatically convert the tuple to a Grammar) --> Grammar
(GrammarOne, GrammarTwo) | (GrammarThree, GrammarFour) # tuple OR tuple --> Python doesn't know how to do this.
G(GrammarOne, GrammarTwo) | G(GrammarThree, GrammarFour) # This works
OR((GrammarOne, GrammarTwo), (GrammarThree, GrammarFour))
GrammarOne | "foo" # This works"foo" | GrammarOne # This works"foo" | "bar" # string OR string --> Python doesn't know how to do this
L("foo") | L("bar") # This works
OR("foo", "bar") # This works too
--
You received this message because you are subscribed to the Google Groups "modgrammar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modgrammar+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.