Skip to content
garfix edited this page Dec 28, 2013 · 1 revision

Here is an example of how to generate a English sentence from a set of relations:


// Generate "Lord Byron was influenced by John Milton."

 $relations = "
	sentence(?e) and
	mood(?e, Declarative) and
	voice(?e, Passive) and
	isa(?e, Influence) and
	tense(?e, Past) and
	subject(?e, ?s) and
	object(?e, ?o) and
	name(?s, 'John Milton') and
	name(?o, 'Lord Byron')
 ";

$Parser = new SemanticStructureParser();
$Generator = new Generator();

$Sentence = $Parser->parse($relations);
$Grammar = GrammarFactory::getGrammar('en')
$text = $Generator->generate($Grammar, $Sentence);

More examples can be found in the GenerationTest class.

Clone this wiki locally