本文整理汇总了PHP中MemModel::unite方法的典型用法代码示例。如果您正苦于以下问题:PHP MemModel::unite方法的具体用法?PHP MemModel::unite怎么用?PHP MemModel::unite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemModel
的用法示例。
在下文中一共展示了MemModel::unite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUnite
function testUnite()
{
$_SESSION['test'] = 'MemModel unite test';
$model1 = new MemModel();
$stat = new Statement(new Resource('http://www.example.org/sub1'), new Resource('http://www.example.org/pred1'), new Resource('http://www.example.org/obj1'));
$stat2 = new Statement(new Resource('http://www.example.org/sub2'), new Resource('http://www.example.org/pred2'), new Resource('http://www.example.org/obj2'));
$stat3 = new Statement(new Resource('http://www.example.org/sub3'), new Resource('http://www.example.org/pred3'), new Resource('http://www.example.org/obj3'));
$model1->add($stat);
$model1->add($stat2);
$model2 = new MemModel();
$model2->add($stat);
$model2->add($stat2);
$model2->add($stat3);
$res = new MemModel();
$res = $model1->unite($model2);
$this->assertEqual(3, $res->size());
$this->assertTrue($res->contains($stat));
$this->assertTrue($res->contains($stat2));
$this->assertTrue($res->contains($stat3));
}
示例2: MwRdfInPage
function MwRdfInPage($article)
{
$text = $article->getContent(true);
$parser = new Parser();
$text = $parser->preprocess($text, $article->mTitle, new ParserOptions());
preg_match_all("@<rdf>(.*?)</rdf>@s", $text, $matches, PREG_PATTERN_ORDER);
$content = $matches[1];
$rdf = implode(' ', array_values($content));
$model = null;
if (strlen($rdf) > 0) {
$parser->mOutputType = OT_HTML;
$rdf = $parser->replaceVariables($rdf);
global $default_prefixes, $wgRdfNamespaces;
require_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_N3;
$parser = new N3Parser();
$parser->baseURI = $article->mTitle->getFullURL();
$prefixes = array_merge($default_prefixes, $wgRdfNamespaces, MwRdfNamespacePrefixes());
$prelude = "";
foreach ($prefixes as $prefix => $uri) {
$prelude .= "@prefix {$prefix}: <{$uri}> .\n";
}
# XXX: set correct properties
$model = $parser->parse2model($prelude . $rdf);
if ($model === false) {
global $RDFS_comment;
$model = ModelFactory::getDefaultModel();
$model->add(new Statement(MwRdfArticleResource($article), $RDFS_comment, MwRdfLiteral("Error parsing in-page RDF: " . $parser->errors[0] . "\n code here: \n '" . $prelude . $rdf . "'", null, "en")));
} else {
# To make it unique, we unite with an empty model
$fake = new MemModel();
$model =& $fake->unite($model);
}
}
return $model;
}