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


PHP ARC2::getSemHTMLParser方法代码示例

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


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

示例1: run

 public function run($r, $graphUri)
 {
     include_once 'ARC2/ARC2.php';
     $uri = $r->getUri();
     $url = $r->getLocator();
     $config = array('auto_extract' => 0);
     $parser = ARC2::getSemHTMLParser();
     @$parser->parse($url);
     @$parser->extractRDF('rdfa');
     $triples = $parser->getTriples();
     if (!is_array($triples) || count($triples) == 0) {
         return false;
     }
     $data = array();
     $data[$uri] = array();
     // transform arc2 triple to RDF_PHP structure
     // TODO: blank nodes?
     foreach ($triples as $triple) {
         // but only for the requested resource and not ignored properties
         // TODO: use a generic fetch preset from linkeddata wrapper
         if ($triple['s'] == $uri && array_search($triple['p'], $this->_config->ignore->toArray()) === false) {
             // create resource objects
             if ($triple['o_type'] == 'uri') {
                 $data[$uri][$triple['p']][] = array('type' => 'uri', 'value' => $triple['o']);
             }
             // create literal objects
             if ($triple['o_type'] == 'literal') {
                 $newObject = array('type' => 'literal', 'value' => $triple['o']);
                 if ($triple['o_lang'] != '') {
                     $newObject['lang'] = $triple['o_lang'];
                 }
                 if ($triple['o_datatype'] != '') {
                     $newObject['datatype'] = $triple['o_datatype'];
                 }
                 $data[$uri][$triple['p']][] = $newObject;
             }
         }
     }
     // set a default class type if configured and no type was extracted
     if (!isset($data[$uri][EF_RDF_TYPE]) && isset($this->_config->defaultClass)) {
         $data[$uri][EF_RDF_TYPE][] = array('type' => 'uri', 'value' => $this->_config->defaultClass);
     }
     $fullResult['status_description'] = "RDFa data found for URI {$uri}";
     $fullResult['add'] = $data;
     $fullResult['status_codes'] = array(Erfurt_Wrapper::NO_MODIFICATIONS);
     $fullResult['status_codes'][] = Erfurt_Wrapper::RESULT_HAS_ADD;
     return $fullResult;
 }
开发者ID:FTeichmann,项目名称:Erfurt,代码行数:48,代码来源:RdfaWrapper.php

示例2: extractRDFa

/**
 * Extrahiert eingebettetes rdfa aus einer beliebigen HTML Seite und
 * speichert es im triple store
 * @param string $url
 * @return Response Ein Responseobjekt
 */
function extractRDFa($url)
{
    global $ep;
    // Wenn es die URL im Graph schon gibt, nichts machen
    if (graphContainsUrl($url)) {
        $res = new Response(null, "URL {$url} already visited, skip indexing");
        return $res;
    } else {
        $parser = ARC2::getSemHTMLParser();
        $parser->parse($url);
        $parser->extractRDF('rdfa');
        // triple Darstellung
        $triples = $parser->getTriples();
        // Wenn kein rdfa gefunden wurde
        if (count($triples) < 1) {
            $res = new Response(null, "URL {$url} contains no rdfa");
            return $res;
        }
        // in Datenbank einfügen
        $ep->insert($triples, $url);
        $res = new Response(null, "URL {$url}: added " . count($triples) . " triples");
        return $res;
    }
}
开发者ID:neumann89,项目名称:FUB-xml-project6-2013,代码行数:30,代码来源:defaultEndpoint.php

示例3: header

<?php

//error_reporting(0);
include 'config.php';
include ARC_DIR . 'ARC2.php';
include_once BASE_DIR . 'checkLogin.php';
ARC2::inc('PMJ_ResourceGraphPlugin');
//require_once(CLASSES_DIR . 'Recording.php');
header('Content-type: application/json');
$store = ARC2::getStore($config);
if (!$store->isSetUp()) {
    $store->setUp();
}
/* Parse what ARC can from the page */
//this can take a bit long, though.
$parser = ARC2::getSemHTMLParser();
$parser->parse($_POST['page']);
$parser->extractRDF('dc rdfa');
$triples = $parser->getTriples();
$q = 'INSERT INTO <>  { ' . $parser->toNTriples($triples) . ' } ';
$parseRS = $store->query($q);
$graph = ARC2::getComponent('PMJ_ResourceGraphPlugin', $graphConfig);
$recordingRes = ARC2::getComponent('PMJ_ResourcePlusPlugin', $graphConfig);
$userURI = $_SESSION['userURI'];
$recordingURI = 'http://data.rubrick-jetpack.org/Recordings/' . sha1($userURI . time());
$recordingRes->setURI($recordingURI);
$recordingRes->addPropValue('rdf:type', 'r:Recording', 'uri');
$recordingRes->addPropValue('sioc:has_creator', $userURI, 'uri');
$recordingRes->addPropValue('r:hasPage', $_POST['page'], 'uri');
$recordingRes->addPropValue('dcterms:created', date('c'), 'literal', 'xsd:dateTime');
$recordingRes->addPropValue('r:hasRubric', $_POST['rubric'], 'uri');
开发者ID:patrickmj,项目名称:Rubrick,代码行数:31,代码来源:postRecording.php

示例4: semhtml

 function semhtml($url, $output, $type = '')
 {
     $parser = ARC2::getSemHTMLParser($this->a);
     $parser->parse($url);
     $parser->extractRDF($type);
     $triples = $parser->getTriples();
     $document = $parser->toTurtle($triples);
     return $this->to_rdf($url, $document, $output);
 }
开发者ID:WebOrganics,项目名称:TransFormr,代码行数:9,代码来源:ARC2_RDFTranformrPlugin.php

示例5: sendPing

function sendPing($to, $message, $base_uri, $verbose = false)
{
    $ret = "<br/>\n";
    $to = trim($to);
    // fetch the user's profile
    $person = new MyProfile($to, $base_uri, SPARQL_ENDPOINT);
    $person->load();
    $profile = $person->get_profile();
    $to_name = $person->get_name();
    $to_email = $person->get_email();
    $pingback_service = $profile->get("pingback:to");
    // set form data
    $source = $_SESSION['webid'];
    // parse the pingback form
    $config = array('auto_extract' => 0);
    $parser = ARC2::getSemHTMLParser($config);
    $parser->parse($pingback_service);
    $parser->extractRDF('rdfa');
    // load triples
    $triples = $parser->getTriples();
    // proceed only if the user has defined a pingback:to relation
    if ($pingback_service != null) {
        if (sizeof($triples) > 0) {
            //echo "<pre>" . print_r($triples, true) . "</pre>\n";
            foreach ($triples as $triple) {
                // proceed only if we have a valid pingback resource
                if ($triple['o'] == 'http://purl.org/net/pingback/Container') {
                    $fields = array('source' => $source, 'target' => $to, 'comment' => $message);
                    // Should really replace curl with an ajax call
                    //open connection to pingback service
                    $ch = curl_init();
                    //set the url, number of POST vars, POST data
                    curl_setopt($ch, CURLOPT_URL, $pingback_service);
                    curl_setopt($ch, CURLOPT_POST, count($fields));
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                    //execute post
                    $return = curl_exec($ch);
                    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                    //close connection
                    curl_close($ch);
                    if ($httpCode == '201' || $httpCode == '202') {
                        $ret .= success('Message delivered!');
                    } else {
                        $ret .= error('Something happened and I couldn\'t deliver the message!');
                        $ret .= "<p>Details:</p>\n";
                        $ret .= "</p>" . $return . "</p>\n";
                    }
                    break;
                }
            }
        } else {
            $ret .= "   <p>{$pingback_service} does not comply with semantic pingback standards! Showing the pingback service page instead.</p>\n";
            // show frame
            $ret .= "   <iframe src=\"{$pingback_service}\" width=\"100%\" height=\"300\">\n";
            $ret .= "   <p>Your browser does not support iframes.</p>\n";
            $ret .= "   </iframe>\n";
        }
    } else {
        // no valid pingback service found, fallback to AKSW
        $ret .= "   <p>Could not find a pingback service for the given WebID. Here is a generic pingback service provided by http://pingback.aksw.org/.</p>\n";
        $ret .= "   <iframe src=\"http://pingback.aksw.org/\" width=\"100%\" height=\"300\">\n";
        $ret .= "   <p>Your browser does not support iframes.</p>\n";
        $ret .= "   </iframe>\n";
    }
    if ($verbose) {
        return $ret;
    }
}
开发者ID:ASDAFF,项目名称:myprofile,代码行数:69,代码来源:Messages.php

示例6: add_rdfa

 /**
  * Add the triples parsed from the supplied RDFa to the graph
  * @param string html the HTML containing RDFa to parse
  * @param string base the base URI against which relative URIs in the Turtle document will be resolved
  */
 function add_rdfa($html, $base = '')
 {
     if ($html) {
         $parser = ARC2::getSemHTMLParser();
         $parser->parse($base, $html);
         $parser->extractRDF('rdfa');
         $this->_add_arc2_triple_list($parser->getTriples());
         unset($parser);
     }
 }
开发者ID:asavagar,项目名称:EU-data-cloud,代码行数:15,代码来源:simplegraph.class.php

示例7: _saveResFromRDFa

 /**
  * Stores all subjects of RDF triples extracted from the RDFa representation of a given fragment in this format:
  * fragmentURI LOOMP:contains resourceURI .
  *
  * @param  Resource    $fragmentRes          Resource Object
  * @param  string      $rdfa          		 RDFa representation of a given fragment
  */
 private function _saveResFromRDFa($fragmentRes, $rdfa)
 {
     $parser = ARC2::getSemHTMLParser();
     $parser->parse('', $rdfa);
     $parser->extractRDF('rdfa');
     $triples = $parser->getTriples();
     $res = array();
     for ($i = 0, $i_max = count($triples); $i < $i_max; $i++) {
         $triple = $triples[$i];
         if ($triple['s_type'] == "uri") {
             if (!in_array($triple['s'], $res)) {
                 $res[] = $triple['s'];
                 $this->rdfModel->add(new Statement($fragmentRes, LOOMP::CONTAINS(), new Resource($triple['s'])));
             }
         }
         if ($triple['o_type'] == 'literal') {
             $obj = new Literal($triple['o'], $triple['o_lang']);
             if ($triple['o_datatype']) {
                 $obj->setDatatype($triple['o_datatype']);
             }
         } else {
             $obj = new Resource($triple['o']);
         }
         $this->rdfModel->add(new Statement(new Resource($triple['s']), new Resource($triple['p']), $obj));
     }
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:33,代码来源:api.php

示例8: __construct

 public function __construct($u)
 {
     $this->_rdfa_parser = ARC2::getSemHTMLParser();
     $this->_rdfa_parser->parse($u);
     $this->_rdfa_parser->extractRDF('rdfa');
     $index = $this->_rdfa_parser->getSimpleIndex(0);
     foreach ($index[$this->Base()] as $prop => $values) {
         $matches = array();
         if (preg_match('!^http://opengraphprotocol.org/schema/(.+)$!i', $prop, $matches)) {
             $p = strtolower($matches[1]);
         } elseif (preg_match('!^http://ogp.me/ns#(.+)$!i', $prop, $matches)) {
             $p = strtolower($matches[1]);
         } else {
             $p = $prop;
         }
         foreach ($values as $value) {
             if ($value['type'] == 'bnode') {
                 continue;
             }
             $this->_data[$p][] = $value['value'];
         }
     }
     return $this;
 }
开发者ID:anubhaBhargava,项目名称:OpenRecommender,代码行数:24,代码来源:OpenGraphNode.php


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