Exemple #1
0
 */
use nlgen\Generator;
require '../../php-nlgen/generator.php';
// execute as php basic0.php 0 0 0 0
class BasicGenerator extends Generator
{
    var $agents = array('Juan', 'Pedro', 'The helpdesk operator');
    var $events = array('started', 'is', 'finished');
    var $actions = array('working on', 'coding', 'doing QA on');
    var $themes = array('Component ABC', 'Item 25', 'the delivery subsystem');
    protected function top($data)
    {
        return $this->person($data[0]) . " " . $this->action($data[1], $data[2]) . " " . $this->item($data[3]);
    }
    protected function person($agt)
    {
        return $this->agents[$agt];
    }
    protected function action($evt, $act)
    {
        return $this->events[$evt] . " " . $this->actions[$act];
    }
    protected function item($thm)
    {
        return $this->themes[$thm];
    }
}
global $argv, $argc;
$gen = BasicGenerator::NewSealed();
print $gen->generate(array_splice($argv, 1)) . "\n";
print_r($gen->semantics());
Exemple #2
0
    protected function action($event, $action)
    {
        return $this->lex->string_for_id($event) . " " . $this->lex->string_for_id($action);
    }
    protected function item($theme)
    {
        return $this->lex->string_for_id($theme);
    }
}
global $argv, $argc;
$lexicon_json = <<<HERE
{
  "juan" :        {"string" : "Juan Perez"},
  "pedro" :       {"string" : "Pedro Gomez"},
  "helpdesk" :    {"string" : "the helpdesk operator"},
  "start" :       {"string" : "started"},
  "ongoing" :     {"string" : "is"},
  "finish":       {"string" : "finished"},
  "general" :     {"string" : "working on"},
  "code" :        [ {"string" : "coding"}, {"string":"doing programming on" } ],
  "qa" :          {"string" : "doing QA on"},
  "comp_abc" :    {"string" : "Component ABC"},
  "itm_25" :      {"string" : "Item 25"},
  "sub_delivery": {"string" : "the delivery subsystem"}
}
HERE;
$gen = BasicGenerator::NewSealed('', $lexicon_json);
// example inputs juan ongoing code sub_delivery
//                helpdesk finish qa itm_25
print $gen->generate(array_splice($argv, 1)) . "\n";
print_r($gen->semantics());
Exemple #3
0
  "start" :       {"string" : "started"},
  "ongoing" :     {"string" : "is"},
  "finish":       {"string" : "finished"},
  "general" :     {"string" : "working on"},
  "code" :        [ {"string" : "coding"}, {"string":"doing programming on" } ],
  "qa" :          {"string" : "doing QA on"},
  "comp_abc" :    {"string" : "Component ABC"},
  "itm_25" :      {"string" : "Item 25"},
  "sub_delivery": {"string" : "delivery subsystem"}
}
HERE;
$onto_json = <<<HERE
{
  "juan" :        {"class" : "person"},
  "pedro" :       {"class" : "person"},
  "helpdesk" :    {"class" : "role"},
  "comp_abc" :    {"class" : "component"},
  "itm_25" :      {"class" : "item"},
  "sub_delivery": {"class" : "subsystem"},
  "person" :      { "requires_determiner":  "no" },
  "role" :        { "requires_determiner":  "yes" },
  "component" :   { "requires_determiner":  "no" },
  "item" :        { "requires_determiner":  "no" },
  "subsystem" :   { "requires_determiner":  "yes" }
}
HERE;
$gen = BasicGenerator::NewSealed($onto_json, $lexicon_json);
// example inputs juan ongoing code sub_delivery
//                helpdesk finish qa itm_25
print $gen->generate(array_splice($argv, 1)) . "\n";
print_r($gen->semantics());