Class |
RiTa |
||||
---|---|---|---|---|---|
Name |
grammar |
||||
Description | Creates a new RiGrammar object: a probabilistic context-free grammar for text-generation. You may use any of the RiScript features in a grammar, including transforms, sequences, and assignments.rg = RiTa.grammar(theRules); RiTa grammars are valid JSON formatted strings (or JS objects or Java Maps), as follows { If you're working in JavaScript, you can simply pass a JavaScript object instead. If you're not sure whether your grammar is valid JSON, check it at jsonlint.com. Note: a RiGrammar object will assign (by default) equal weights to all choices in a rule. You can adjust the weights by adding 'multipliers' as described in the RiScript reference. For example, in the rule below 'terminal1' will be chosen twice as often as the two other choices. rule2: ( terminal1 [2] | terminal2 | $rule1 ) |
||||
Example |
rg = RiTa.grammar(rulesObject); |
||||
Parameters |
|
||||
Returns |
|
||||
Related | see the tutorial Generating with Grammars | ||||
Syntax |
// Initialize an empty RiGrammar object |
||||
Platform | Java / JavaScript | ||||