public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); //Look if the Article has a category if (!preg_match("/" . WIKIMEDIA_CATEGORY . ":/", $pageID, $match)) { //match all categories if (preg_match_all("/\\[\\[" . WIKIMEDIA_CATEGORY . ":(.*)\\]\\]/", $pageSource, $matches, PREG_SET_ORDER)) { //empty ClassArray $this->ClassArray = array(); foreach ($matches as $match) { //remove the category-label $Category = preg_replace("/\\|.*/", "", $match[1]); $query = "select Arg2 from facts where Relation = 'subClassOf' and Arg1 = 'wikicategory_" . mysql_escape_string(str_replace(" ", "_", $Category)) . "'"; $queryresult = mysql_query($query, $this->DBlink) or die("Anfrage fehlgeschlagen: " . mysql_error()); while ($row = mysql_fetch_array($queryresult, MYSQL_ASSOC)) { $this->ClassArray[$row["Arg2"]] = true; } } foreach ($this->ClassArray as $subject => $bool) { $YagoClass = str_replace("wordnet_", "", $subject); $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI(RDF_TYPE, false), RDFtriple::URI(DB_YAGO_NS . $this->camel($YagoClass, "_"))); } } } return $result; }
public function generate($subjectName, $propertyName, $value) { $result = array(); $value = Util::replaceWikiLinks($value); //TODO: WARUM NUR IN DIESEM FALL CITE RAUSNEHMEN? preg_match_all("/{{2}cite.*?\\}{2}/i", $value, $matches); foreach ($matches as $match) { if (!array_key_exists(0, $match)) { continue; } $value = str_replace($match[0], Util::replaceTemplates($match[0]), $value); } $value = Util::removeHtmlTags($value); $value = Util::removeHtmlComments($value); // get unit exact type // Some arguments have a fixed type - e.g. weight_lb -> pounds $unitExactType = null; //UnitValueParser::parseValue($propvalue, $this->language, array($unit_type, $unit_exact_type, $propkey)); $parseResultArray = $this->parser->parse($value); if (isset($parseResultArray)) { foreach ($parseResultArray as $parseResults) { $parsedDataType = $parseResults[1]; if ($parsedDataType == "") { $parsedDataType = null; } $result[] = new RDFtriple(RDFtriple::page($subjectName), RDFtriple::URI(DB_ONTOLOGY_NS . $propertyName), RDFtriple::Literal((string) $parseResults[0], $parsedDataType, null)); } } else { //TODO: GENERATE LOGFILE WITH UNPARSED VALUES $result[] = new RDFTriple(RDFtriple::page($subjectName), RDFtriple::URI(DB_ONTOLOGY_NS . $propertyName), RDFtriple::Literal($value)); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); $meta = $this->additionalInfo; //generate dc modified $date = date('c'); $datatype = XS_DATETIME; $o = RDFtriple::Literal($date, $datatype, ""); $this->log('trace', $o->toString()); $result->addTriple($this->getPageURI(), RDFtriple::URI(DC_MODIFIED, false), $o); //OAIIDENTIFIER $this->log(DEBUG, $meta['oaiId']); $result->addTriple($this->getPageURI(), RDFtriple::URI(DBM_OAIIDENTIFIER, false), new RDFLiteral($meta['oaiId'], XS_INTEGER)); //REVISION $revisionURI = 'http://' . $meta['language'] . '.wikipedia.org/w/index.php?title='; $revisionURI .= urlencode($pageID) . '&oldid=' . $meta['revision']; //http://en.wikipedia.org/w/index.php?title=Robotics&oldid=293678514 $this->log(DEBUG, $revisionURI); $result->addTriple($this->getPageURI(), RDFtriple::URI(DBM_REVISION, false), RDFtriple::URI($revisionURI)); $editLink = 'http://' . $meta['language'] . '.wikipedia.org/w/index.php?title='; $editLink .= urlencode($pageID) . '&action=edit'; $this->log(DEBUG, $editLink); $result->addTriple($this->getPageURI(), RDFtriple::URI(DBM_EDITLINK, false), RDFtriple::URI($editLink)); return $result; }
function __construct($metainfo) { $this->uri = RDFtriple::page($metainfo['pageTitle']); $this->language = $metainfo['language']; $this->oaiId = $metainfo['oaiId']; $this->graphURI = Options::getOption('graphURI'); $this->annotationGraphURI = Options::getOption('annotationGraphURI'); $this->generateOWLAxiomAnnotations = Options::getOption('generateOWLAxiomAnnotations'); $this->languageProperties = Options::getOption('stringPredicateWithForeignlanguages'); $this->debug_turn_off_insert = Options::getOption('debug_turn_off_insert'); $this->debug_run_tests = Options::getOption('debug_run_tests'); $this->hash = new Hash($this->oaiId, $this->uri->getURI()); //$this->metainfo = $metainfo; $this->subjectSPARULpattern = $this->uri->toSPARULPattern(); if (Options::isOptionSet('predicateFilter')) { $p = Options::getOption('predicateFilter'); $this->log(WARN, 'currently not working'); } if (Options::isOptionSet('objectFilter')) { $o = Options::getOption('objectFilter'); $this->log(WARN, 'currently not working'); } if (Options::isOptionSet('predicateObjectFilter')) { $po = Options::getOption('predicateObjectFilter'); $this->log(WARN, 'currently not working'); } }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); $pageID = encodeLocalName($pageID); // Remove Template as this is already extracted by the Infobox Extractor // Find subtemplates and remove Subtemplates, which are listed as ignored! preg_match_all('~\\{((?>[^{}]+)|(?R))*\\}~x', $pageSource, $subTemplates); foreach ($subTemplates[0] as $key => $subTemplate) { $subTemplate = preg_replace("/(^\\{\\{)|(\\}\\}\$)/", "", $subTemplate); // Cut Brackets / {} $pageSource = str_replace('{{' . $subTemplate . '}}', '', $pageSource); } // Extract internal Semantic Links $findSemanticLinks = preg_match_all('/(\\[\\[)([a-zA-z0-9\\- _]+)(::)([^\\]]+)\\]\\]/', $pageSource, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $result->addTriple(RDFtriple::page($pageID), RDFtriple::predicate(encodeLocalName($match[2])), RDFtriple::page($match[4])); } // Extract Literals $findSemanticLinks = preg_match_all('/(\\[\\[)([a-zA-Z\\-_ ]+)(:=)([^\\]]+)\\]\\]/', $pageSource, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $triple = array(); $triple = parseAttributeValue($match[4], $pageID, $match[2]); // object, object_is, datatype(, language) $lexicalForm = $triple[0]; $datatype = $triple[2]; $predicate = propertyToCamelCase(encodeLocalName($match[2])); // Continue if empty String if ($lexicalForm == null) { continue; } $result->addTriple(RDFtriple::page($pageID), RDFTriple::predicate($predicate), RDFtriple::literal($lexicalForm, $datatype, 'en')); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); $image_ar = $this->extract_image_url($pageSource); $image = ucfirst($image_ar[0]); $width = $image_ar[1]; if ($image == null) { return $result; } $ImageURL = $this->make_image_url($image, false, true); $ImageURLSmall = $this->make_image_url($image, $width); $image = str_replace(" ", "_", trim($image)); if (!URI::validate($ImageURL) || !URI::validate($ImageURLSmall)) { return $result; } // Add fullsize image $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI(FOAF_DEPICTION), RDFtriple::URI($ImageURL)); // Add depiction has thumbnail $result->addTriple(RDFtriple::URI($ImageURL), RDFtriple::URI(FOAF_THUMBNAIL), RDFtriple::URI($ImageURLSmall)); // Add object has thumbnail $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI(DBO_THUMBNAIL), RDFtriple::URI($ImageURLSmall)); // add triples linking back to the Wikipedia image description $image = urlencode($image); $wikipediaImageDescription = 'http://' . $this->language . '.wikipedia.org/wiki/Image:' . $image; $result->addTriple(RDFtriple::URI($ImageURLSmall), RDFtriple::URI(DC_RIGHTS), RDFtriple::URI($wikipediaImageDescription)); $result->addTriple(RDFtriple::URI($ImageURL), RDFtriple::URI(DC_RIGHTS), RDFtriple::URI($wikipediaImageDescription)); return $result; }
public function generate($subjectName, $propertyName, $value) { $result = array(); $parseResults = $this->parser->parse($value); ob_start(); $str = "Date parser \n"; $str .= "value was: {$value} \n"; print_r($parseResults); $str .= ob_get_contents(); ob_end_clean(); Logger::debug($str); if (!isset($parseResults)) { return $result; } $datePattern = "/\\d\\d\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])/"; /* if(preg_match($datePattern, $parseResults) != 1) return $result; $isValidDate = checkdate( substr($parseResults, 5, 2), substr($parseResults, 8, 2), substr($parseResults, 0, 4)); */ $isValidDate = true; if ($isValidDate) { $result[] = new RDFtriple(RDFtriple::page($subjectName), RDFtriple::URI(DB_ONTOLOGY_NS . $propertyName), RDFtriple::Literal($parseResults[0], $parseResults[1], null)); //print_r($result); } else { $result[] = new RDFtriple(RDFtriple::page($subjectName), RDFtriple::URI(DB_ONTOLOGY_NS . $propertyName), RDFtriple::Literal($parseResults, null, null)); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); $category = Util::getMediaWikiNamespace($this->language, MW_CATEGORY_NAMESPACE); if (preg_match_all("/" . $category . ":(.*)/", $pageID, $match)) { $result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_PREFLABEL, false), RDFtriple::Literal($this->decode_title($pageTitle), NULL, $this->language)); $result->addTriple($this->getPageURI(), RDFtriple::URI(RDF_TYPE, false), RDFtriple::URI(SKOS_CONCEPT, false)); if (preg_match_all("/\\[\\[" . $category . ":(.*)\\]\\]/", $pageSource, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { // split on | sign if (strpos($match[1], '|') === false) { $object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($match[1]); } else { $split = explode('|', $match[1]); $object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($split[0]); } try { $object = RDFtriple::URI($object); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; continue; } $result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_BROADER, false), $object); } } } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); $CleanSource = $this->remove_wikicode($pageSource); $LongAbstract = $this->extract_abstract($CleanSource, 3000, false, false); $result->addTriple(RDFtriple::page($pageID), RDFtriple::predicate("abstract"), RDFtriple::Literal($LongAbstract, NULL, $this->language)); return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); if ($this->language == "en") { $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://xmlns.com/foaf/0.1/page"), RDFtriple::URI("http://wikicompany.org/wiki/" . URI::wikipediaEncode($pageTitle))); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); if ($this->decode_title($pageTitle) == NULL) { return $result; } $result->addTriple($this->getPageURI(), RDFtriple::URI(RDFS_LABEL, false), RDFtriple::Literal($this->decode_title($pageTitle), NULL, $this->language)); return $result; }
public function generate($subjectName, $propertyName, $value) { $result = array(); $parseResults = $this->parser->parse($value); foreach ($parseResults as $mystring) { $result[] = new RDFtriple(RDFtriple::page($subjectName), RDFtriple::URI(DB_ONTOLOGY_NS . $propertyName), RDFtriple::Literal($mystring)); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); $CleanSource = $this->remove_wikicode($pageSource); $Abstract = $this->extract_abstract($CleanSource); //$LongAbstract = $this->extract_abstract($CleanSource, 3000, false, false); $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://www.w3.org/2000/01/rdf-schema#comment"), RDFtriple::Literal($Abstract, NULL, $this->language)); return $result; }
public function getPredicateTriples() { $predicateTriples = new ExtractionResult($this->pageID, $this->language, $this->extractorID); foreach ($this->predicates as $subject => $bool) { // array_push( $predicateTriples, new RDFtriple($subject, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property")); $predicateTriples->addTriple(RDFtriple::URI($subject), RDFtriple::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), RDFtriple::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#Property")); $predicateTriples->addTriple(RDFtriple::URI($subject), RDFtriple::URI("http://www.w3.org/2000/01/rdf-schema#label"), RDFtriple::Literal($this->getPredicateLabel($subject))); } return $predicateTriples; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); $pageID = encodeLocalName($pageID); // Extract Wikipedia Link if (preg_match('/\\{\\{wikipedia\\-c(\\-note)?\\}\\}/', $pageSource)) { $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://www.w3.org/2002/07/owl#sameAs"), RDFtriple::URI("http://dbpedia.org/resource/" . $pageID)); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); $link = $this->findLink($pageSource); if ($link) { $this->log(DEBUG, "Found link {$link}"); $result->addTriple($this->getPageURI(), RDFtriple::URI(FOAF_HOMEPAGE, false), RDFtriple::URI($link, false)); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); // Add fullsize image $ImageURL = $this->extract_image_url($pageSource, $pageTitle); if ($ImageURL == null || !URI::validate($ImageURL)) { return $result; } $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://xmlns.com/foaf/0.1/depiction"), RDFtriple::URI($ImageURL)); return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { // language code in URI uses '-', not '_' $language = str_replace('_', '-', $this->language); $subject = $this->getPageURI(); $predicate = $language == 'en' ? RDFtriple::predicate("wikipage-" . $language) : RDFtriple::URI(FOAF_PAGE, false); $object = RDFtriple::URI("http://" . $language . ".wikipedia.org/wiki/" . URI::wikipediaEncode($pageTitle)); $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); $result->addTriple($subject, $predicate, $object); return $result; }
public function generate($subjectName, $propertyName, $value) { $result = array(); $image = "image"; $parsedText = ActiveAbstractExtractor::stripMarkup($value, $image); $parsedText = trim($parsedText); if ($parsedText != "") { $result[] = new RDFtriple(RDFtriple::page($subjectName), RDFtriple::URI(DB_ONTOLOGY_NS . $propertyName), RDFtriple::Literal($parsedText, null, $this->language)); } return $result; }
public function generate($subjectName, $propertyName, $value) { $result = array(); $value = Util::removeWikiEmphasis($value); //TODO:ADD LANGUAGE AS PARAM $parseResults = $this->parser->parse($value); foreach ($parseResults as $r) { $result[] = new RDFtriple(RDFtriple::page($subjectName), RDFtriple::URI(DB_ONTOLOGY_NS . $propertyName), RDFtriple::page($r)); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); if ($this->language == "en") { $query = "select wsl.url from templatelinks tl inner join page p on p.page_id = tl.tl_from\r\n\t\t\t\t\t\tinner join dbpedia_develop.wordnet_mapping wm on tl.tl_title = wm.infobox\r\n\t\t\t\t\t\tinner join dbpedia_develop.wordnet_synsets_links wsl on wm.ID1 = wsl.synset30ID\r\n\t\t\t\t\t\twhere p.page_title = '" . mysql_escape_string($pageID) . "' and p.page_namespace = 0"; $queryresult = mysql_query($query, $this->DBlink) or die("Query failed:\n{$query}\n" . mysql_error()); while ($row = mysql_fetch_array($queryresult, MYSQL_ASSOC)) { $result->addTriple(RDFtriple::page($pageID), RDFtriple::predicate("wordnet_type"), RDFtriple::URI($row["url"])); } } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $org_language = $this->language; $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); $query = "select page_title, page_namespace, ll.ll_lang,replace(trim(ll_title), ' ', '_')as lang_title from page p inner join langlinks ll on p.page_id = ll.ll_from where p.page_title= '" . mysql_escape_string($pageID) . "' and p.page_namespace <> 14"; $queryresult = mysql_query($query, $this->DBlink) or die(" search unsuccessful: " . mysql_error()); while ($row = mysql_fetch_array($queryresult, MYSQL_ASSOC)) { //$object="http://xxx.dbpedia.org/resource/".URI::wikipediaEncode($row["lang_title"] ); $result->addTriple(RDFtriple::URI("http://" . $org_language . ".dbpedia.org/resource/" . URI::wikipediaEncode($pageID)), RDFtriple::URI(OWL_SAMEAS, false), RDFtriple::URI("http://" . $row["ll_lang"] . ".dbpedia.org/resource/" . URI::wikipediaEncode($row["lang_title"]))); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); // Locate geo coordinates if (preg_match('/<geo>([\\-0-9\\.]+);([\\-0-9\\.]+)[^0-9]*[^<]*<\\/geo>/', $pageSource, $match)) { $lat = $match[1]; $long = $match[2]; $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://www.w3.org/2003/01/geo/wgs84_pos#lat"), RDFtriple::Literal($lat, "http://www.w3.org/2001/XMLSchema#float", NULL)); $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://www.w3.org/2003/01/geo/wgs84_pos#long"), RDFtriple::Literal($long, "http://www.w3.org/2001/XMLSchema#float", NULL)); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); $extlinks = $this->extract_external_links($pageSource, $this->language); while (list($ExtURL, $ExtName) = each($extlinks)) { if (!URI::validate($ExtURL)) { continue; } $result->addTriple(RDFtriple::page($pageID), RDFtriple::predicate("reference"), RDFtriple::URI($ExtURL)); } return $result; }
public function generate($subjectName, $propertyName, $value) { $result = array(); $links = $this->parser->parse($value); foreach ($links as $link) { $link = $this->mediaWikiUtil->toCanonicalWikiCase($link); $link = encodeLocalName($link); $resource = $this->basePath . $link; $result[] = new RDFtriple(RDFtriple::page($subjectName), RDFtriple::URI(DB_ONTOLOGY_NS . $propertyName), RDFtriple::URI($resource)); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); $PersonData = $this->extractPersondata($pageSource, $this->language); //var_dump($PersonData); if ($PersonData != null) { // preg_match("/\[\[en:(.*)\]\]/", $pageSource, $LangLinkmatch); // $PersonData['enPageID'] = str_replace(" ","_",$LangLinkmatch[1]); $WikiDB = new DatabaseWikipedia($this->language); preg_match("/\\[\\[([^\\]]*)\\]\\]/", $PersonData['birthplace'], $Birthplacematch); $Birthplacematch = $this->getLinkForLabeledLink($Birthplacematch); $mySource = $WikiDB->getSource($Birthplacematch); preg_match("/\\[\\[en:(.*)\\]\\]/", $mySource, $LangLinkmatch); $BirthPlace = $LangLinkmatch[1]; preg_match("/\\[\\[([^\\]]*)\\]\\]/", $PersonData['deathplace'], $Deathplacematch); $Deathplacematch = $this->getLinkForLabeledLink($Deathplacematch); $mySource = $WikiDB->getSource($Deathplacematch); preg_match("/\\[\\[en:(.*)\\]\\]/", $mySource, $LangLinkmatch); $DeathPlace = $LangLinkmatch[1]; //var_dump($PersonData); //var_dump($BirthPlace); //var_dump($DeathPlace); //var_dump($Deathplacematch); $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://xmlns.com/foaf/0.1/name"), RDFtriple::Literal($PersonData['name'], null, "de")); $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://xmlns.com/foaf/0.1/givenname"), RDFtriple::Literal($PersonData['givenname'], null, "de")); $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://xmlns.com/foaf/0.1/surname"), RDFtriple::Literal($PersonData['surname'], null, "de")); if ($BirthPlace != "") { $result->addTriple(RDFtriple::page($pageID), RDFtriple::predicate("birthPlace"), RDFtriple::page($BirthPlace)); // $result->addTriple( // RDFtriple::page($pageID), // RDFtriple::URI("http://purl.org/vocab/bio/0.1/event"), // RDFtriple::URI("http://dbpedia.org/resource/" . URI::wikipediaEncode($pageID) . "/Birth")); // $result->addTriple( // RDFtriple::URI("http://dbpedia.org/resource/" . URI::wikipediaEncode($pageID) . "/Birth"); // RDFtriple::URI("http://purl.org/vocab/bio/0.1/place"), // RDFtriple::page($BirthPlace)); } if ($PersonData['birthdate'] != "") { $result->addTriple(RDFtriple::page($pageID), RDFtriple::predicate("birth"), RDFtriple::Literal($PersonData['birthdate'], "http://www.w3.org/2001/XMLSchema#date", null)); } if ($DeathPlace != "") { $result->addTriple(RDFtriple::page($pageID), RDFtriple::predicate("deathPlace"), RDFtriple::page($DeathPlace)); } if ($PersonData['deathdate'] != "") { $result->addTriple(RDFtriple::page($pageID), RDFtriple::predicate("death"), RDFtriple::Literal($PersonData['deathdate'], "http://www.w3.org/2001/XMLSchema#date", null)); } if ($PersonData['description'] != "") { $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://purl.org/dc/elements/1.1/description"), RDFtriple::Literal($PersonData['description'], null, "de")); } $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), RDFtriple::URI("http://xmlns.com/foaf/0.1/Person")); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); if (!preg_match("/Category:/", $pageID, $match)) { if (preg_match_all("/\\[\\[Category:(.*)\\]\\]/", $pageSource, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $Category = preg_replace("/\\|.*/", "", $match[1]); $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://www.w3.org/2004/02/skos/core#subject"), RDFtriple::page("Category:" . $Category)); } } } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { //create a new Extraction Result to hold all extrated Triples $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); //Look for {{chembox header}} in PageSource if (preg_match("/{{chembox header}}/", $pageSource, $match)) { //DO SOME PARSING //Add a Triple for each Property $result->addTriple($this->getPageURI(), RDFtriple::URI(DB_MY_CHEM_PROPERTY, false), RDFtriple::Literal("my_value")); //Add each Predicate to the Predicate Collection $this->allPredicates->addPredicate("my_chem_property"); } return $result; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); $extlinks = $this->extract_external_links($pageSource, $this->language); while (list($ExtURL, $ExtName) = each($extlinks)) { // Replace single quotes with %27 $ExtURL = str_replace("'", "%27", $ExtURL); $ExtURL = str_replace("\\", "\\\\", $ExtURL); if (!URI::validate($ExtURL)) { continue; } $result->addTriple($this->getPageURI(), RDFtriple::URI(DB_REFERENCE, false), RDFtriple::URI($ExtURL)); } return $result; }
public function generate($subjectName, $propertyName, $value) { $result = array(); if (strpos($value, "{{") !== false) { $value = Util::replaceTemplates($value); } $value = Util::removeHtmlTags($value); $value = Util::removeHtmlComments($value); $value = Util::removeWikiEmphasis($value); $parseResults = $this->parser->parse($value); if (isset($parseResults)) { $result[] = new RDFtriple(RDFtriple::page($subjectName), RDFtriple::URI(DB_ONTOLOGY_NS . $propertyName), RDFtriple::Literal($parseResults)); } else { //TODO: ADD DEGUB LOGFILE FOR UN-PARSED TRIPLES $result[] = new RDFtriple(RDFtriple::page($subjectName), RDFtriple::URI(DB_ONTOLOGY_NS . $propertyName), RDFtriple::Literal($value)); } return $result; }