Skip to content

Commit 860aff8

Browse files
committed
Add (working, but untested) support for blank nodes
1 parent 5d7f719 commit 860aff8

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

classes/parsers/RDFIO_ARC2ToWikiConverter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function convert( $arc2Triples, $arc2ResourceIndex, $arc2NSPrefixes ) {
6767
*/
6868
$propertyDataType = null;
6969
switch ( $triple['o_type'] ) {
70+
case 'bnode':
7071
case 'uri':
7172
// Create new page for the object
7273
$object = $uriToTitleConv->convert( $triple['o'] );

classes/parsers/RDFIO_URIToWikiTitleConverter.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function convert( $uri ) {
4141
$convStrategies = array(
4242
'getExistingTitleForURI',
4343
'applyGlobalSettingForPropertiesToUseAsWikiTitle',
44+
'parseBNode',
4445
'shortenURINamespaceToAliasInSourceRDF',
4546
'extractLocalPartFromURI',
4647
'useValueAsIs'
@@ -96,7 +97,23 @@ function applyGlobalSettingForPropertiesToUseAsWikiTitle( $uri ) {
9697
}
9798

9899
/**
99-
* Strategy 3: Abbreviate the namespace to its NS prefix as configured in
100+
* Strategy 3: Check if $uri is a blank node, and if so, add 'BNode_' to the wiki title.
101+
* @param $uri
102+
* @return string
103+
*/
104+
function parseBNode( $uri ) {
105+
$title = '';
106+
107+
if ( substr( $uri, 0, 2 ) == '_:' ) {
108+
$bnodeId = explode( ':', $uri )[1];
109+
$title = 'Blank_node_' . substr( $bnodeId, 3);
110+
}
111+
112+
return $title;
113+
}
114+
115+
/**
116+
* Strategy 4: Abbreviate the namespace to its NS prefix as configured in
100117
* mappings in the parser (default ones, or provided as part of the
101118
* imported data)
102119
*/
@@ -121,7 +138,7 @@ function shortenURINamespaceToAliasInSourceRDF( $uri ) {
121138
}
122139

123140
/**
124-
* Strategy 4: As a default, just try to get the local part of the URL
141+
* Strategy 5: As a default, just try to get the local part of the URL
125142
*/
126143
function extractLocalPartFromURI( $uri ) {
127144
$title = '';
@@ -135,7 +152,7 @@ function extractLocalPartFromURI( $uri ) {
135152
}
136153

137154
/**
138-
* Strategy 5: Just use the value as is, as if it was a literal value
155+
* Strategy 6: Just use the value as is, as if it was a literal value
139156
*/
140157
function useValueAsIs( $uri ) {
141158
return $uri;

0 commit comments

Comments
 (0)