本文整理汇总了PHP中Statement::getObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Statement::getObject方法的具体用法?PHP Statement::getObject怎么用?PHP Statement::getObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statement
的用法示例。
在下文中一共展示了Statement::getObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: equals
public function equals(Statement $toTest)
{
if ($toTest instanceof Statement && $this->getSubject()->equals($toTest->getSubject()) && $this->getPredicate()->equals($toTest->getPredicate()) && $this->getObject()->equals($toTest->getObject())) {
if ($this->isQuad() && $toTest->isQuad() && $this->getGraph()->equals($toTest->getGraph())) {
return true;
} elseif ($this->isTriple() && $toTest->isTriple()) {
return true;
}
}
return false;
}
示例2: getObject
/**
* Returns the object.
*
* @return Resource
* @access public
*/
function getObject()
{
return $this->statement->getObject();
}
示例3: mapFreebaseStatement
public function mapFreebaseStatement(Statement $statement)
{
$subject = $this->mapFreebaseUri($statement->getSubject());
$this->statistics['triple-mapped-subject']++;
$isValueCvt = $this->cvtProvider->isCVTProperty($statement->getPredicate());
$predicate = $this->mapFreebaseProperty($statement->getPredicate());
$this->statistics['triple-mapped-subject-property']++;
$objects = [];
$qualifiers = [];
$source = [];
$isReviewed = $this->reviewedFacts->isReviewedFact($statement->getSubject(), $statement->getPredicate());
if ($isValueCvt && !$this->propertyExpectCvt($predicate)) {
$this->statistics['triple-value-cvt']++;
//CVT management
$cvt = $this->cvtProvider->getCVT($statement->getObject());
//Special cases
$specialMapping = [];
if ($predicate instanceof SpouseProperty) {
if (array_key_exists('<http://rdf.freebase.com/ns/people.marriage.type_of_union>', $cvt)) {
switch ($cvt['<http://rdf.freebase.com/ns/people.marriage.type_of_union>'][0]) {
case '<http://rdf.freebase.com/ns/m.04ztj>':
case '<http://rdf.freebase.com/ns/m.0jgjn>':
case '<http://rdf.freebase.com/ns/m.0dl5ys>':
case '<http://rdf.freebase.com/ns/m.03m4r>':
case '<http://rdf.freebase.com/ns/m.01bl8s>':
case '<http://rdf.freebase.com/ns/m.075xk9>':
$predicate = new WikidataProperty('P26', false, 'wikibase-item');
break;
case '<http://rdf.freebase.com/ns/m.01g63y>':
throw new Mappingfailure();
//TODO: What to do with https://www.freebase.com/m/01g63y Domestic partnership
/*$predicate = new WikidataProperty('P451', false, 'wikibase-item');
break;*/
//TODO: What to do with https://www.freebase.com/m/01g63y Domestic partnership
/*$predicate = new WikidataProperty('P451', false, 'wikibase-item');
break;*/
default:
throw new Exception('Unknown mariage type: ' . $cvt['<http://rdf.freebase.com/ns/people.marriage.type_of_union>'][0]);
}
$this->statistics['triple-used']++;
} else {
//By default we concider that it is a union
$predicate = new WikidataProperty('P26', false, 'wikibase-item');
}
$specialMapping['/ns/people.marriage.spouse'] = $predicate;
}
foreach ($cvt as $cvtPredicate => $values) {
foreach ($values as $value) {
try {
$property = $this->mapFreebaseProperty($cvtPredicate, $specialMapping);
if ($property instanceof ValueProperty) {
$objects[] = $this->mapValue($value, $property);
$this->statistics['triple-used']++;
} elseif ($property instanceof WikidataProperty) {
list($pred, $value) = $this->mapQualifierValue($cvtPredicate, $property, $value);
if ($value !== $subject) {
//Filter qualifiers that have as value the subject. Useful when the relation is used in both directions in Wikidata
if ($property->isSource()) {
$source[str_replace('P', 'S', $pred)][] = $value;
} else {
$qualifiers[$pred][] = $value;
}
$this->statistics['triple-used']++;
}
} else {
throw new Exception('Invalid property as qualifier');
}
if ($this->reviewedFacts->isReviewedFact($statement->getObject(), $cvtPredicate)) {
$isReviewed = true;
//We should maybe be harder and ask for everything reviewed
}
} catch (Mappingfailure $e) {
//don't fail for qualifiers
}
}
}
if (empty($objects) && $predicate instanceof WikidataProperty) {
if (!array_key_exists($predicate->getPid(), $qualifiers)) {
//Find main property
throw new Mappingfailure();
}
$objects = $qualifiers[$predicate->getPid()];
unset($qualifiers[$predicate->getPid()]);
}
} else {
$objects[] = $this->mapValue($statement->getObject(), $predicate);
}
if (!$predicate instanceof WikidataProperty) {
throw new Mappingfailure();
}
$statements = [];
foreach ($objects as $object) {
//Special formatting
if ($predicate->getPid() === 'P774') {
if (preg_match('/^(\\d{2})(\\d{5})$/', $object, $m)) {
$object = $m[1] . '-' . $m[2];
}
} elseif ($predicate->getPid() === 'P274') {
$object = str_replace(['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'], ['₁', '₂', '₃', '₄', '₅', '₆', '₇', '₈', '₉', '₀'], $object);
} elseif (in_array($predicate->getPid(), ['P1953', 'P1954', 'P1955']) && !is_numeric($object)) {
//.........这里部分代码省略.........