public function _make_linguistic_object($fieldsAndValues) { $logger = Logger::getLogger('LinguisticObjects.makeLinguisticObject'); $logger->debug("\$fieldsAndValues= " . print_r($fieldsAndValues, TRUE)); $type = $fieldsAndValues['type']; $logger->debug("type= {$type}"); $obj = NULL; if ($type == 'n' || $type == 'a' || $type == 'e' || $type == 'c') { $obj = new NounRoot($fieldsAndValues); array_push(self::$rootIDs, $obj->id()); } elseif ($type == 'v') { $obj = new VerbRoot($fieldsAndValues); array_push(self::$rootIDs, $obj->id()); } elseif ($type == 's') { $obj = new Source($fieldsAndValues); array_push(self::$sourceIDs, $obj->id()); } elseif ($type == 'sn' || $type == 'sv' || $type == 'q') { $obj = new Suffix($fieldsAndValues); array_push(self::$affixIDs, $obj->id()); } elseif ($type == 'tn') { $obj = new NounEnding($fieldsAndValues); array_push(self::$affixIDs, $obj->id()); } elseif ($type == 'tv') { $obj = new VerbEnding($fieldsAndValues); array_push(self::$affixIDs, $obj->id()); } elseif ($type == 'vw') { $obj = new VerbWord($fieldsAndValues); self::$verbWords[$object->getVerb()] = $obj; } elseif ($type == 'pr') { $obj = new Pronoun($fieldsAndValues); array_push(self::$rootIDs, $obj->id()); } elseif ($type == 'pd' || $type == 'ad') { $obj = new Demonstrative($fieldsAndValues); array_push(self::$rootIDs, $obj->id()); $roots = explode(' ', $obj->get_root()); foreach ($roots as $a_root) { $newFieldsAndValues = $fieldsAndValues; $newFieldsAndValues['morpheme'] = $a_root; $newFieldsAndValues['root'] = $a_root; $new_obj = new Demonstrative($newFieldsAndValues); array_push(self::$rootIDs, $new_obj->id()); } } else { $logger->debug("type '{$type}' not supported yet"); } return $obj; }
public function testToPassive_EN_2() { $text = 'v(to /offer, /give, /bring) c(s.t.) to someone (-mut)'; $trTg = 'to be offered, given, brought to someone (-mut)'; $tr = VerbRoot::toPassive($text, 'en'); $this->assertEquals($trTg, $tr, ''); }
<?php /* * Created on 2010-11-10 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */ set_include_path('..'); require_once "lib/parseCSV.php"; require_once "linguisticobjects/LinguisticObjects.php"; $fd = fopen('c:/eclipse_workspace/InuktitutNew-PHP/divers/verbes_sens_francais.txt', 'r'); while (($ligne = fgets($fd)) != null) { if (preg_match('/^[a-z\\/0-9\\&]+ : (.+)$/', $ligne, $match)) { $sens = $match[1]; $sensPrepare = VerbRoot::prepareSenseForTransformation_FR($sens); $trans = VerbRoot::toTransitive_FR($sensPrepare); echo "-------------------------------------------------------------------\n"; echo "{$sens}\n"; echo "------\n"; echo "{$sensPrepare}\n"; echo "------\n"; echo $trans . "\n"; } } close($fd);