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


PHP EasyRdf_Graph::parseFile方法代码示例

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


在下文中一共展示了EasyRdf_Graph::parseFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createGraph

  /**
   * Creates an EasyRdf_Graph object from the given URI.
   *
   * @param string $uri
   *     URL of a web resource or path of the cached file.
   * @param string $type
   *    Format of the document.
   *
   * @throws \Doctrine\Common\Proxy\Exception\InvalidArgumentException
   *    If invalid type or URL is passed as parameters.
   */
  protected function createGraph($uri, $type) {
    /*
     * Initialize an EasyRdf_Graph object using
     * _construct(string $uri = null, string $data = null,
     *     string $format = null)
     */
    if (!is_string($type) or $type == NULL or $type == '') {
      throw new InvalidArgumentException("\$type should be a string and cannot be null or empty");
    }
    if (!is_string($uri) or $uri == NULL or $uri == '') {
      throw new InvalidArgumentException("\$uri should be a string and cannot be null or empty");
    }

    try {
      if (preg_match('#^http#i', $uri) === 1) {
        $this->graph = new \EasyRdf_Graph($uri, NULL, $type);
        $this->graph->load();
      }
      else {
        $this->graph = new \EasyRdf_Graph(NULL);
        $this->graph->parseFile($uri);
      }
      $this->iterateGraph();
    }
    catch (\Exception $e) {
      throw new InvalidArgumentException("Invalid uri + $e");
    }

  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:40,代码来源:EasyRdfConverter.php

示例2: getTriples

 protected function getTriples($file)
 {
     if (!file_exists($file)) {
         throw new Exception($file . ' not found');
     }
     // validate the file to import
     $parser = new tao_models_classes_Parser($file, array('extension' => 'rdf'));
     $parser->validate();
     if (!$parser->isValid()) {
         throw new common_Exception('Invalid RDF file ' . $file);
     }
     $modelDefinition = new EasyRdf_Graph();
     $modelDefinition->parseFile($file);
     /*
     $graph = $modelDefinition->toRdfPhp();
     $resources = $modelDefinition->resources();
     */
     $format = EasyRdf_Format::getFormat('php');
     $data = $modelDefinition->serialise($format);
     $triples = array();
     foreach ($data as $subjectUri => $propertiesValues) {
         foreach ($propertiesValues as $prop => $values) {
             foreach ($values as $k => $v) {
                 $triples[] = array('s' => $subjectUri, 'p' => $prop, 'o' => $v['value'], 'l' => isset($v['lang']) ? $v['lang'] : '');
             }
         }
     }
     return $triples;
 }
开发者ID:oat-sa,项目名称:extension-tao-devtools,代码行数:29,代码来源:class.RdfDiff.php

示例3: createModel

 /**
  * @author "Lionel Lecaque, <lionel@taotesting.com>"
  * @param string $namespace
  * @param string $data xml content
  */
 public function createModel($namespace, $data)
 {
     $modelId = $this->getModelId($namespace);
     if ($modelId === false) {
         common_Logger::d('modelId not found, need to add namespace ' . $namespace);
         $this->addNewModel($namespace);
         //TODO bad way, need to find better
         $modelId = $this->getModelId($namespace);
     }
     $modelDefinition = new EasyRdf_Graph($namespace);
     if (is_file($data)) {
         $modelDefinition->parseFile($data);
     } else {
         $modelDefinition->parse($data);
     }
     $graph = $modelDefinition->toRdfPhp();
     $resources = $modelDefinition->resources();
     $format = EasyRdf_Format::getFormat('php');
     $data = $modelDefinition->serialise($format);
     foreach ($data as $subjectUri => $propertiesValues) {
         foreach ($propertiesValues as $prop => $values) {
             foreach ($values as $k => $v) {
                 $this->addStatement($modelId, $subjectUri, $prop, $v['value'], isset($v['lang']) ? $v['lang'] : null);
             }
         }
     }
     return true;
 }
开发者ID:nagyist,项目名称:generis,代码行数:33,代码来源:class.ModelFactory.php

示例4: testParseWebId

 public function testParseWebId()
 {
     $graph = new EasyRdf_Graph();
     $graph->parseFile(fixturePath('webid.ttl'), 'turtle');
     $me = $graph->resource('http://www.example.com/myfoaf#me');
     $modulus = $me->get('cert:key')->get('cert:modulus');
     $this->assertStringEquals('CB24ED85D64D794B69C701C186ACC059501E856000F661C93204D8380E07191C' . '5C8B368D2AC32A428ACB970398664368DC2A867320220F755E99CA2EECDAE62E' . '8D15FB58E1B76AE59CB7ACE8838394D59E7250B449176E51A494951A1C366C62' . '17D8768D682DDE78DD4D55E613F8839CF275D4C8403743E7862601F3C49A6366' . 'E12BB8F498262C3C77DE19BCE40B32F89AE62C3780F5B6275BE337E2B3153AE2' . 'BA72A9975AE71AB724649497066B660FCF774B7543D980952D2E8586200EDA41' . '58B014E75465D91ECF93EFC7AC170C11FC7246FC6DED79C37780000AC4E079F6' . '71FD4F207AD770809E0E2D7B0EF5493BEFE73544D8E1BE3DDDB52455C61391A1', $modulus);
     $this->assertInternalType('string', $modulus->getValue());
     $this->assertSame(NULL, $modulus->getLang());
     $this->assertSame('xsd:hexBinary', $modulus->getDatatype());
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:11,代码来源:HexBinaryTest.php

示例5: dissertationen

function dissertationen($atts)
{
    EasyRdf_Namespace::set('bibo', 'http://purl.org/ontology/bibo/');
    EasyRdf_Namespace::set('sd', 'http://symbolicdata.org/Data/Model#');
    EasyRdf_Namespace::set('dct', 'http://purl.org/dc/terms/');
    $people = new EasyRdf_Graph("http://symbolicdata.org/Data/People/");
    $people->parseFile("http://symbolicdata.org/rdf/People.rdf");
    //$people->parseFile("/home/graebe/git/SD/web/rdf/People.rdf");
    $out = "\n\n<h2 align=\"center\">Habilitationen</h2>\n\n";
    $out .= displayAll(getDissertations('habil'), $people);
    $out .= "\n\n<h2 align=\"center\">Promotionen</h2>\n\n";
    $out .= displayAll(getDissertations('phd'), $people);
    return $out;
}
开发者ID:symbolicdata,项目名称:web,代码行数:14,代码来源:Dissertations.php

示例6: casystems

function casystems()
{
    EasyRdf_Namespace::set('sd', 'http://symbolicdata.org/Data/Model#');
    EasyRdf_Namespace::set('dct', 'http://purl.org/dc/terms/');
    EasyRdf_Namespace::set('owl', 'http://www.w3.org/2002/07/owl#');
    $people = new EasyRdf_Graph("http://symbolicdata.org/Data/People/");
    $people->parseFile("http://symbolicdata.org/rdf/People.rdf");
    //$people->parseFile("/home/graebe/git/SD/web/rdf/People.rdf");
    $systems = new EasyRdf_Graph("http://symbolicdata.org/Data/CA-Systems/");
    $systems->parseFile("http://symbolicdata.org/rdf/CA-Systems.rdf");
    //$systems->parseFile("/home/graebe/git/SD/web/rdf/CA-Systems.rdf");
    $out = displaySystems($systems, $people);
    return $out;
}
开发者ID:symbolicdata,项目名称:web,代码行数:14,代码来源:Systems.php

示例7: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configArgument = $input->getArgument('config');
     if ($configArgument) {
         $parser = new Parser();
         $config = $parser->parse(file_get_contents($configArgument));
         unset($parser);
     } else {
         $config = [];
     }
     $processor = new Processor();
     $configuration = new TypesGeneratorConfiguration();
     $processedConfiguration = $processor->processConfiguration($configuration, [$config]);
     $processedConfiguration['output'] = realpath($input->getArgument('output'));
     if (!$processedConfiguration['output']) {
         throw new \RuntimeException('The specified output is invalid');
     }
     $graphs = [];
     foreach ($processedConfiguration['rdfa'] as $rdfa) {
         $graph = new \EasyRdf_Graph();
         if ('http://' === substr($rdfa['uri'], 0, 7) || 'https://' === substr($rdfa['uri'], 0, 8)) {
             $graph->load($rdfa['uri'], $rdfa['format']);
         } else {
             $graph->parseFile($rdfa['uri'], $rdfa['format']);
         }
         $graphs[] = $graph;
     }
     $relations = [];
     foreach ($processedConfiguration['relations'] as $relation) {
         $relations[] = new \SimpleXMLElement($relation, 0, true);
     }
     $goodRelationsBridge = new GoodRelationsBridge($relations);
     $cardinalitiesExtractor = new CardinalitiesExtractor($graphs, $goodRelationsBridge);
     $ucfirstFilter = new \Twig_SimpleFilter('ucfirst', 'ucfirst');
     $loader = new \Twig_Loader_Filesystem(__DIR__ . '/../../templates/');
     $twig = new \Twig_Environment($loader, ['autoescape' => false, 'debug' => $processedConfiguration['debug']]);
     $twig->addFilter($ucfirstFilter);
     if ($processedConfiguration['debug']) {
         $twig->addExtension(new \Twig_Extension_Debug());
     }
     $logger = new ConsoleLogger($output);
     $entitiesGenerator = new TypesGenerator($twig, $logger, $graphs, $cardinalitiesExtractor, $goodRelationsBridge);
     $entitiesGenerator->generate($processedConfiguration);
 }
开发者ID:api-platform,项目名称:schema-generator,代码行数:47,代码来源:GenerateTypesCommand.php

示例8: flatImport

 /**
  * Imports the rdf file into the selected class
  * 
  * @param string $file
  * @param core_kernel_classes_Class $class
  * @return common_report_Report
  */
 private function flatImport($file, core_kernel_classes_Class $class)
 {
     $report = common_report_Report::createSuccess(__('Data imported successfully'));
     $graph = new EasyRdf_Graph();
     $graph->parseFile($file);
     // keep type property
     $map = array(RDF_PROPERTY => RDF_PROPERTY);
     foreach ($graph->resources() as $resource) {
         $map[$resource->getUri()] = common_Utils::getNewUri();
     }
     $format = EasyRdf_Format::getFormat('php');
     $data = $graph->serialise($format);
     foreach ($data as $subjectUri => $propertiesValues) {
         $resource = new core_kernel_classes_Resource($map[$subjectUri]);
         $subreport = $this->importProperties($resource, $propertiesValues, $map, $class);
         $report->add($subreport);
     }
     return $report;
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:26,代码来源:class.RdfImporter.php

示例9: DirectoryIterator

<?php

require_once '.php/EasyRdf.php';
$graph = new EasyRdf_Graph();
foreach (new DirectoryIterator(dirname(__FILE__)) as $dir_entry) {
    if ($dir_entry->getExtension() == 'ttl') {
        $graph->parseFile($dir_entry->getPathname());
    }
}
$sidebar = '';
// TODO: construct TOC
if (preg_match('|^/([0-9A-Za-z&-]+)$|', $_SERVER['REQUEST_URI'], $matches) && file_exists($matches[1] . '.ttl')) {
    // TODO
    $link = $matches[1];
    $content = '';
    $title = '';
} else {
    http_response_code(404);
    $content = '<h1>404 Not Found</h1>';
    $title = '404 Not Found';
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title><?php 
echo $title ? "{$title} &mdash; " : '';
?>
开发者ID:conreality,项目名称:kb.conreality.org,代码行数:31,代码来源:index.php

示例10: header

        $item->property = $property;
        $item->value = $uri;
        $result[] = $item;
    }
    return $result;
}
// print '<pre>';
if (isset($_GET['resource'])) {
    $requested_resource = 'univ:' . $_GET['resource'];
    //////////////////////////////////////////////////////////////////////////////////////
    // Set the namespace related to our RDF file namespace
    // Note:
    // For the standard namespaces like rdf,rdf,owl,foaf is already defined by the API
    // so we do not need to explicitly define it here
    // ////////////////////////////////////////////////////////////////////////////////////
    EasyRdf_Namespace::set('univ', 'http://www.semanticweb.org/workshop/2016/ontologies/university#');
    // instansiate the Graph Object
    $graph = new EasyRdf_Graph();
    //////////////////////////////////////////////////////////////////
    // load the RDF file into the graph object
    // Note:
    // Here we load the RDF via file I/O path, if you want to load
    // the RDF via HTTP then use load() method instead ($graph->load())
    // ////////////////////////////////////////////////////////////////
    $graph->parseFile('../ontology/universitas-live-example.ttl', 'turtle');
    // At this stage, we are ready to process the graph
    // ==========================================================
    $response_object = graph_walker($graph, $requested_resource);
    header('Content-Type:application/json');
    echo json_encode($response_object);
}
开发者ID:takin,项目名称:workshop-semantic-web,代码行数:31,代码来源:graph-api.php

示例11: get

 public function get()
 {
     $graph = new Graph();
     $graph->parseFile('sample.ttl');
     return $graph;
 }
开发者ID:linkeddatacenter,项目名称:BOTK-rdf,代码行数:6,代码来源:sample.php

示例12: testParseFileRelativeUri

 public function testParseFileRelativeUri()
 {
     $graph = new EasyRdf_Graph();
     $count = $graph->parseFile(fixturePath('foaf.rdf'));
     $this->assertSame(14, $count);
     $doc = $graph->get('foaf:PersonalProfileDocument', '^rdf:type');
     $this->assertClass('EasyRdf_Resource', $doc);
     $this->assertRegExp('|^file://.+/fixtures/foaf\\.rdf$|', $doc->getUri());
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:9,代码来源:GraphTest.php

示例13: uniqid

$uniqid = uniqid();
$suchbegriff = str_replace(" ", "+", $_GET["qname"]);
//$suchbegriff='123apfelkuchen';
$rdf = "";
if (isset($_GET["rdf"])) {
    $rdf = $_GET["rdf"];
}
$basedir = dirname(realpath(__FILE__));
$root = $basedir;
$ldfu = $root . '/ldfu/bin/ldfu.sh';
$n3_programm = $root . '/n3-files/chefkoch.n3';
$input = 'http://manke-hosting.de/wrapper/index.php/explore/' . $suchbegriff;
$output = $root . '/output/' . $suchbegriff . '.nt';
if (!file_exists($output)) {
    $command = 'sh ' . $ldfu . ' ' . '-i ' . $input . ' ' . '-p ' . $n3_programm . ' ' . '-o ' . $output;
    shell_exec($command);
}
$graph->parseFile($output);
//$graph ->parseFile('/Users/raphaelmanke/Downloads/linked-data-fu-0.9.9/streuselkuchen3.nt');
//$me = $foaf->primaryTopic();
//echo $graph->dump('html');
$resources = $graph->resources();
$namespace = new EasyRdf_Namespace();
$namespace->set('rezept', "http://manke-hosting.de/ns-syntax#");
$rezepte = $graph->resourcesMatching('rezept:RezeptName');
if ($rdf == "true") {
    header("Content-Type: text/turtle; charset=utf-8");
    echo $graph->serialise("turtle");
} else {
    include 'results/rezept.php';
}
开发者ID:RaphaelManke,项目名称:LOD-Seminar,代码行数:31,代码来源:results.php

示例14: foreach

                        $xml = file_get_contents($filePath);
                        $xmlObject = simplexml_load_string($xml);
                        $namespace = 'xsd';
                        if ($vocabulary == 'xsd') {
                            $namespace = 'xs';
                        }
                        $children = $xmlObject->children($namespace, true);
                        foreach ($children->complexType as $v) {
                            $results[] = $vocabulary . ':' . (string) $v->attributes()->name;
                        }
                        foreach ($children->simpleType as $v) {
                            $results[] = $vocabulary . ':' . (string) $v->attributes()->name;
                        }
                    } elseif ($value['extension'] == 'rdf' || $value['extension'] == 'html') {
                        $graph = new EasyRdf_Graph();
                        $graph->parseFile($filePath);
                        $rdfPhp = $graph->toRdfPhp();
                        foreach ($rdfPhp as $key => $resource) {
                            if (strpos($key, $value['namespace']) === 0) {
                                $key = str_replace($value['namespace'], $vocabulary . ':', $key);
                                $results[] = $key;
                            }
                        }
                    }
                }
            }
            $app->response->headers->set('Content-Type', 'application/json');
            $app->response->write(json_encode($results));
        });
    });
});
开发者ID:soutaito,项目名称:IMIDataConverter,代码行数:31,代码来源:api.php

示例15: uniqid

<?php

require_once 'EasyRdf.php';
header('Content-Type: text/turtle; charset=UTF-8');
//$graph = EasyRdf_Graph::newAndLoad('http://manke-hosting.de/wrapper/index.php/explore/apfelkuchen');
$graph = new EasyRdf_Graph();
$out = "";
$uniqid = uniqid();
//$me = $foaf->primaryTopic();
//echo $graph->dump('html');
//print_r($graph ->get("rdf:type") );
$graph->parseFile('/Users/raphaelmanke/Downloads/linked-data-fu-0.9.9/schokokuchen.nt');
//$me = $foaf->primaryTopic();
//echo $graph->dump('html');
$resources = $graph->resources();
$namespace = new EasyRdf_Namespace();
$namespace->set('rezept', "http://manke-hosting.de/ns-syntax#");
echo $graph->serialise("turtle");
//print_r($graph->allOfType("rdf:RezeptName"));
/*
	foreach ($resources as $value) {
		if ($value -> get("rdf:type", "arecipe:Recipe") != ""){
			echo $value;
		}
		echo "bla" . "<br>";
		print_r( $value ->all('^rdf:type') );
	} 
*/
开发者ID:RaphaelManke,项目名称:LOD-Seminar,代码行数:28,代码来源:graph.php


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