コード例 #1
0
 /**
  * Adds the descriptions of the given entity to the RDF graph.
  *
  * @param string $entityLName
  * @param TermList $descriptions
  */
 public function addDescriptions($entityLName, TermList $descriptions)
 {
     foreach ($descriptions->toTextArray() as $languageCode => $description) {
         if ($this->languages !== null && !isset($this->languages[$languageCode])) {
             continue;
         }
         $this->writer->about(RdfVocabulary::NS_ENTITY, $entityLName)->say(RdfVocabulary::NS_SCHEMA_ORG, 'description')->text($description, $languageCode);
     }
 }
 private function injectDescriptions(array &$entityRecord, TermList $descriptions)
 {
     if (!isset($entityRecord['descriptions'])) {
         $entityRecord['descriptions'] = array();
     }
     foreach ($descriptions->toTextArray() as $lang => $text) {
         $entityRecord['descriptions'][$lang] = array('language' => $lang, 'value' => $text);
     }
 }
コード例 #3
0
ファイル: TermListTest.php プロジェクト: SRMSE/cron-wikidata
 public function testGivenTerms_toTextArrayReturnsTermsInFormat()
 {
     $list = new TermList(array(new Term('en', 'foo'), new Term('de', 'bar')));
     $this->assertEquals(array('en' => 'foo', 'de' => 'bar'), $list->toTextArray());
 }