I now managed, (using ARC2 and SMWWriter, in a MediaWiki extension) to populate Semantic MediaWiki pages with triples, from a snippet of RDF/XML (Thanks to Egon Willighagen for the RDF-ized NMRShiftDB data, submitted further below), yay! But ... as you can see, using the full URI:s as wiki names is not a good idea. URI:s as wiki titles is ugly ... and the predicates in this case even got truncated and all treated as the same one, since they had hashes in it, which MediaWiki obviously doesn't allow in titles), so that's the whole background for our talking so much about the "equivalent URI handler" (mentioned here for example), which is thought to be a configurable handler of mappings from URI patterns to (sensible) wiki titles. Also, optimally the same pattern can then be used both on import and export so that the format is kept, allowing to use SMW as a (collaborative) RDF editor! (which is one of the main motivations for my GSoC project).
Well, the hard bits (URI -> Wiki title mapping) remains. Diving in to it now ...
The RDF/XML Test snippet:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:nmr="http://www.nmrshiftdb.org/onto#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:chem="http://www.blueobelisk.org/chemistryblogs/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:bibo="http://purl.org/ontology/bibo/">
<rdf:Description rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=234">
<nmr:moleculeId>234</nmr:moleculeId>
<foaf:homepage rdf:resource="http://nmrshiftdb.ice.mpg.de/portal/js_pane/P-Results/nmrshiftdbaction/showDetailsFromHome/molNumber/234"/>
<chem:casnumber>62994-47-2</chem:casnumber>
<owl:sameAs rdf:resource="http://bio2rdf.org/cas:62994-47-2"/>
<chem:inchi>InChI=1/C15H22O3/c1-13(2)7-4-8-14(3)12(13)6-5-11(9-16)15(14,18)10-17/h5,9-10,12,18H,4,6-8H2,1-3H3/t12-,14-,15+/m0/s1</chem:inchi>
<owl:sameAs rdf:resource="http://rdf.openmolecules.net/?InChI=1/C15H22O3/c1-13(2)7-4-8-14(3)12(13)6-5-11(9-16)15(14,18)10-17/h5,9-10,12,18H,4,6-8H2,1-3H3/t12-,14-,15+/m0/s1"/>
<chem:inchikey>
QGMWDUUHVVLHNP-AEGPPILIBL</chem:inchikey>
<nmr:hasSpectrum rdf:resource="http://pele.farmbio.uu.se/nmrshiftdb/?spectrumId=4735"/>
<dc:title>warburganal</dc:title>
</rdf:Description>
<rdf:Description rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?spectrumId=4735">
<nmr:spectrumId>4735</nmr:spectrumId>
<nmr:spectrumType>13C</nmr:spectrumType>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p0">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">17.6</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p1">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">18.3</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p2">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">22.6</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p3">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">26.5</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p4">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">31.7</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p5">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">33.5</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p6">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">33.5</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p7">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">41.8</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p8">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">42.0</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p9">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">42.2</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p10">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">78.34</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p11">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">140.99</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p12">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">158.3</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p13">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">193.4</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p14">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">203.0</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:hasPeak><nmr:peak rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?s4735p15">
<nmr:hasShift rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">0</nmr:hasShift>
</nmr:peak></nmr:hasPeak>
<nmr:temperature>298</nmr:temperature>
<nmr:solvent>Chloroform-D1 (CDCl3)</nmr:solvent>
<nmr:field>50</nmr:field>
</rdf:Description>
<rdf:Description rdf:about="http://pele.farmbio.uu.se/nmrshiftdb/?moleculeId=2151">
<nmr:moleculeId>2151</nmr:moleculeId>
<foaf:homepage rdf:resource="http://nmrshiftdb.ice.mpg.de/portal/js_pane/P-Results/nmrshiftdbaction/showDetailsFromHome/molNumber/2151"/>
<chem:inchi>InChI=1/C15H24O/c1-10-4-7-15-11(2)12(9-16)8-14(15,3)6-5-13(10)15/h8,10-11,13,16H,4-7,9H2,1-3H3/t10-,11+,13+,14+,15+/m0/s1</chem:inchi>
<owl:sameAs rdf:resource="http://rdf.openmolecules.net/?InChI=1/C15H24O/c1-10-4-7-15-11(2)12(9-16)8-14(15,3)6-5-13(10)15/h8,10-11,13,16H,4-7,9H2,1-3H3/t10-,11+,13+,14+,15+/m0/s1"/>
<chem:inchikey>
GJNXTRPTZOVADS-PWRGDLIEBU</chem:inchikey>
<nmr:hasSpectrum rdf:resource="http://pele.farmbio.uu.se/nmrshiftdb/?spectrumId=3407"/>
<dc:title>Subergorgiol</dc:title>
</rdf:Description>
</rdf:RDF>
Comments
Terribly slow
Also, it is terribly slow ... have to see if I can have SMWWriter write more than one property per edit.
Well, after solving some bugs
Well, after solving some bugs (caused by my own) it's not THAT slow, only quite so ... but what else to expect ... it does a page edit for each triple so ...
Need help!!!
Hi Samuel,
I need help import RDF/XML into SMW. I've also post this as an issue on code.google.com
What steps will reproduce the problem?
1. go to Special:RDFImport page and leave the textarea content intact or input custom RDF content
2. press 'Import' button
3. next page always shows the folowing:
"Unexpected non-MediaWiki exception encountered, of type "UsageException"
notoken: The token parameter must be set"
What is the expected output?
do not know as I've never seen one
What do you see instead?
"Unexpected non-MediaWiki exception encountered, of type "UsageException"
notoken: The token parameter must be set"
What version of the product are you using?
MediaWiki 1.15.4
PHP 5.2.9
MySQL 5.1.32
most recent ARC extennsions
On what operating system?
Windows Vista Home with XAMPP and remote MySQL db server
I appreciate your help!
OS
Hello! Thanks for testing
Hello!
Thanks for testing the extension out.
I have seen that error myself at some moment, but I think I fixed it, since that.
I assume you are using the really really latest version of the extension (I'm updating things almost every hour right now). Also note that I just changed to a new google code repo:http://code.google.com/p/smwrdfio/
Also, I just realized I have forgot to tell about a patch of SMWWriter that has to be done.
It is available now at http://saml.rilspace.org/smwwriter-fixesfor-rdfio-20100716.patch
Apply it by placing it in the SMWWriter folder and run:
patch -p0 < smwwriter-fixesfor-rdfio-20100716.patch
In case the patch doesn't work, I have made a patched version of SMWWriter.php at:
http://saml.rilspace.org/SMWWriter.php.txt
...which you can download (remove ".txt" in the filename afterwards) and replace the current SMWWriter with.
Let me know if the error remains!
Best
// Samuel
Fixed Now!
Samuel,
Many Thanks for updating the code! I was able to import my RDF files into the db. It seems to work good despite the slowness.
Also, may not be a biggie, but I keep getting the Warning:
Warning: Missing argument 1 for RDFIOStore::getOrigURIURI(), called in C:\xampp\htdocs\mediawiki1154\extensions\RDFIO\RDFStore.php on line 33 and defined in C:\xampp\htdocs\mediawiki1154\extensions\RDFIO\RDFStore.php on line 10
I will keep you updated should anything come up.
Oleg
Patching
Samuel,
I am doing development on a Windows box and if one has TortoiseSVN, one may right-click and apply patch automatically.
You may want to include this in your Wiki instructions.
Also, could you please upload a ZIP of your extensions + LocalSettings.php into google code/Uploads, if you could please.
Many Thanks!
Yes, I'll be happy to add
Yes, I'll be happy to add that instruction. Could you please formulate a phrase that is correct, and then I can include it?
I'm a quite reluctant to uploading the zipped extensions and LocalSettings, since there will be multiple places to update (so that sometimes one will forget one of them), and will cause confusion to users.
I have done more testing today though, and figured out more on how to properly install it. For example, when I tested, it appeared that I had to download the latest MediaWiki in order to get it to work! 1.14 did not work :/
I have updated the install instructions with this info, and corrected a number of other errors in it (and one bug in the setup page for the ARC store) so I'm quite convinced that things should work a lot better now if following the new instructions, and checking out fresh code.
Sure, no problem. Patching
Sure, no problem.
Patching Instructions for Windows (XP, Vista, 7) users
Note: the following instructions assume that you have installed TortoiseSVN Subversion Client.
Information: http://tortoisesvn.tigris.org/
Download: http://tortoisesvn.net/downloads
1. obtain a [patch-filename].patch file
2. copy file into directory containing the files to be patched
3. right-click on a [patch-filename].patch file to bring up a menu and select [TortoiseSNV] | [Apply patch...]
4. your selection will bring up a [TortoiseMerge] window and [File Patches]
5. right-click on a file you would like to patch to preview, patch selected or patch all files
6. after patching is done, press [Save] to save your work.
Many thanks! What name
Many thanks!
What name should I include as credit for the instructions? Anything more than "Oleg"? :)
Best
Samuel
No probs! :) Oleg
No probs! :)
Oleg Simakoff
osimakoff@gmail.com
BTW, doinf the all-new install right now. Also, the link http://saml.rilspace.org/SMWWriter.php.txt returns Error 500
Ah, thanks for reporting! ...
Ah, thanks for reporting! ... it seems to be some security issue with file endings, so I renamed the file to SMWWriter-php.txt instead, and updated the URL. Now seems to work: http://saml.rilspace.org/SMWWriter-php.txt
Samuel
Samuel!!! Your latest
Samuel!!!
Your latest instructions work flawlessly! I am now able to import RDF and see the semantic data.
Thanks and have a wonderful weekend!
Oleg
Ah, how good to hear! Then
Ah, how good to hear!
Wish you the same, now we can both have a nice weekend! :)
Fix
Samuel,
On line 33 in ../RDFIO/RDFStore.php and argument needs to be passed into the function getOrigURIURI()
I have passed an $origuri and the warning is gone now. You may want to update your code and rerelease to fix this issue.
(line 33 - fixed)
$origuriuri = $this->getOrigURIURI($origuri);
Many Thanks and keep up great work!
Oleg
Ah, thanks for
Ah, many thanks for reporting!
But I see now that this variable is actually not used (or not anymore), so I think the correct change would be (to avoid passing an unneeded variable) to change line 10 in RDFStore.php to:
function getOrigURIURI() {
(that is, remove '$uri' ).
Will commit within an hour or so, after seeing that it doesn't cause other errors.
Great Thanks!
SMWWriter started acting up on me all of a sudden.
It's giving me a mysterious error:
Fatal error: Call to a member function getHash() on a non-object in C:\xampp\htdocs\mediawiki1154\extensions\SMWWriter\api\SMWWriter.php on line 82
stuck again... :)
Thanks!
Yes, indeed, I've seen these
Yes, indeed, I've seen these as well. By debugging code I found out that sometimething strange happens in SMWWriter sometimes.
Around line 694 or so (can vary depending on my edits), in the remove_value function, I had to add a check:
before the line:
So, the remove_value function now looks like so:
(I'll need to compile better patches later ... and hopefully have Denny to fix these)
Best
Samuel
...another error
Sorry to keep bugging you, Samuel, but I'm determined to make it work today :)
I get another error at line 225
return $entity->getSubject();
Fatal error: Call to a member function getSubject() on a non-object in C:\xampp\htdocs\mediawiki1154\extensions\SMWWriter\api\SMWWriter.php on line 225
...if I check for null, like so:
the error trickles down to:
Catchable fatal error: Argument 2 passed to SMWWriterData::contains() must be an instance of SMWDataValue, null given, called in C:\xampp\htdocs\mediawiki1154\extensions\SMWWriter\api\SMWWriter.php on line 608 and defined in C:\xampp\htdocs\mediawiki1154\extensions\SMWWriter\api\SMWWriter.php on line 172
the nulls seem to be passed around
No prob! It'v much valuable
No prob! It'v much valuable to have people testing things out!
Ok,these errors seem to appear for some kind of data, and not for others.
Is it possible for you to share a bit of the RDF/XML which causes the error for you?
Cheers,
Samuel
Data
Sure, here it is. As you can see, it's pretty simple. I tried modding the coded but got way too far and got stuck :)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<rdf:RDF xmlns="http://www.geonames.org/ontology#" xmlns:cc="http://creativecommons.org/ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:wgs84_pos="http://www.w3.org/2003/01/geo/wgs84_pos#">
<Feature rdf:about="http://sws.geonames.org/4744091/">
<name>Alexandria</name>
<alternateName xml:lang="nl">Alexandria</alternateName>
<alternateName xml:lang="zh">亚历山德里亚</alternateName>
<alternateName xml:lang="en">Alexandria</alternateName>
<alternateName xml:lang="ru">Александрия</alternateName>
<alternateName xml:lang="pl">Alexandria</alternateName>
<alternateName xml:lang="fr">Alexandria</alternateName>
<alternateName xml:lang="de">Alexandria</alternateName>
<alternateName xml:lang="sv">Alexandria</alternateName>
<alternateName xml:lang="post">22320</alternateName>
<alternateName xml:lang="ja">アレクサンドリア</alternateName>
<alternateName xml:lang="pt">Alexandria</alternateName>
<featureClass rdf:resource="http://www.geonames.org/ontology#P"/>
<featureCode rdf:resource="http://www.geonames.org/ontology#P.PPL"/>
<inCountry rdf:resource="http://www.geonames.org/countries/#US"/>
<countryCode>US</countryCode>
<population>127273</population>
<postalCode>22320</postalCode>
<wgs84_pos:lat>38.8048356</wgs84_pos:lat>
<wgs84_pos:long>-77.0469214</wgs84_pos:long>
<nearbyFeatures rdf:resource="http://sws.geonames.org/4744091/nearby.rdf"/>
<locationMap rdf:resource="http://www.geonames.org/4744091/alexandria.html"/>
</Feature>
</rdf:RDF>
...or this
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<rdf:RDF xmlns="http://www.geonames.org/ontology#" xmlns:cc="http://creativecommons.org/ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:wgs84_pos="http://www.w3.org/2003/01/geo/wgs84_pos#">
<Feature rdf:about="http://sws.geonames.org/4744709/">
<name>Arlington</name>
<alternateName xml:lang="zh">阿靈頓縣</alternateName>
<alternateName xml:lang="nl">Arlington</alternateName>
<alternateName xml:lang="eo">Arlington</alternateName>
<alternateName xml:lang="en">Arlington</alternateName>
<alternateName xml:lang="ru">Арлингтон</alternateName>
<alternateName xml:lang="it">Arlington</alternateName>
<alternateName xml:lang="fr">Arlington</alternateName>
<alternateName xml:lang="de">Arlington</alternateName>
<alternateName xml:lang="es">Arlington</alternateName>
<alternateName xml:lang="post">22245</alternateName>
<alternateName xml:lang="sv">Arlington</alternateName>
<alternateName xml:lang="bs">Arlington</alternateName>
<alternateName xml:lang="no">Arlington</alternateName>
<alternateName xml:lang="ja">アーリントン</alternateName>
<alternateName xml:lang="pt">Arlington</alternateName>
<featureClass rdf:resource="http://www.geonames.org/ontology#P"/>
<featureCode rdf:resource="http://www.geonames.org/ontology#P.PPL"/>
<inCountry rdf:resource="http://www.geonames.org/countries/#US"/>
<countryCode>US</countryCode>
<population>185360</population>
<postalCode>22245</postalCode>
<wgs84_pos:lat>38.8810112826588</wgs84_pos:lat>
<wgs84_pos:long>-77.1042823791504</wgs84_pos:long>
<nearbyFeatures rdf:resource="http://sws.geonames.org/4744709/nearby.rdf"/>
<locationMap rdf:resource="http://www.geonames.org/4744709/arlington.html"/>
</Feature>
</rdf:RDF>
Ok, will look at it! Btw, I
Ok, will look at it!
Btw, I suggest we continue reporting and discussing errors on the issue tracker! :) ... will make things much easier to track!
Best
Samuel
Thanks
Samuel,
Thanks! I will get the new code and give it a shot.
also, could you perhaps zip up and post your 'extensions' + LocalSettings.php directory? It is possible that I have missed something in the setup and that's why I keep getting errors.
This would also help out tremendously !
Thanks again!
Oleg
Both the data snippets work
Both the data snippets work flawlessly for me. But I have in fact fiddled with SMWWriter even after I last told you, I think.
I have therefore created a new patch with all the changes I have currently applied to SMWWriter, and updated the link to it in the Install instructions.
I also just (one second ago) commited one of the changes you suggested.
So now the code in the trunk combined with the new patch, should need to solve it AFAIS.
Hope it helps!
Samuel
Updated install instructions!
I just created an updated install instruction page now:
http://code.google.com/p/smwrdfio/wiki/InstallAll
... which includes the patch, and some new settings for LocalSettings.php.