当前位置: 首页>>代码示例>>PHP>>正文


PHP Statement::getPredicate方法代码示例

本文整理汇总了PHP中Statement::getPredicate方法的典型用法代码示例。如果您正苦于以下问题:PHP Statement::getPredicate方法的具体用法?PHP Statement::getPredicate怎么用?PHP Statement::getPredicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Statement的用法示例。


在下文中一共展示了Statement::getPredicate方法的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;
 }
开发者ID:guitarmarx,项目名称:Saft,代码行数:11,代码来源:AbstractStatement.php

示例2: getPredicate

 /**
  * Returns the predicate.
  *
  * @return Resource
  * @access	public
  */
 function getPredicate()
 {
     return $this->statement->getPredicate();
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:10,代码来源:Quad.php

示例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)) {
//.........这里部分代码省略.........
开发者ID:randyamiel,项目名称:freebase-wikidata-converter,代码行数:101,代码来源:lib.php


注:本文中的Statement::getPredicate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。