Comments (12)
Hi @tonicebrian Thanks for the proposal.
I could do the same for all other standard vocabularies but if you think it doesn't belong here, I can create a library just with the vocabularies in it and just depend on rdf4h
Take a look at @fabianmeyer 's rdf4h-vocabulary-generator and rdf4h-vocabulary packages. The approach uses template Haskell to read a schema from a Turtle file, and generates a Haskell module at compile time e.g.
$(genVocabulary "resources/shacl.ttl")
The two advantages I see are:
- You don't have to implement the Haskell modules by hand for each vocabulary.
- You avoid mistakes e.g. typo mistakes in URIs, property strings, etc.
Two possible disadvantages are:
- You are committed to the choices made by the implementation of
genVocabulary
, which might not meet your needs. - If you wanted to use this template Haskell technique for your own schemas, then you only get the module at compile time, limiting the ability to inspect it during development and IDE features e.g.
it would be super handy if common terms for SKOS were part of the library so I could use autocomplete
in which case you'd need to compile your SKOS vocab module with genVocabulary
first, then develop another module that uses SKOS.hs
.
@tonicebrian does rdf4h-vocabulary-generator meet your needs?
from rdf4h.
Hi @tonicebrian good idea, and this has been something I've been meaning to add to this library. For SKOS, and other commonly used vocabularies.
I will reply to you here when I've added this functionality.
from rdf4h.
Hi Rob, I'm willing to contribute this myself. If you have some ideas about structure, just put here a minimal template/structure and I will follow it. Otherwise I could do a "proposal" for SKOS and discuss that in the PR.
I'm planning to use rdf4h in a project and the missing things in the library are short term the vocabularies and long term the ability to work with Namedgraphs, so I'd prefer that you spend your time working on harder issues
from rdf4h.
Hey, @robstewart57 did you like the structure I picked for the Vocabularies in #108 . I could do the same for all other standard vocabularies but if you think it doesn't belong here, I can create a library just with the vocabularies in it and just depend on rdf4h
from rdf4h.
Hi @robstewart57 yes, I on paper it solves completely what I was looking for. But I tried to compile it and I get compilation errors so maybe it is abandoned.
rdf4h-vocabulary > /home/cebrian/GIT/rdf4h-vocabulary/src/Data/RDF/Vocabulary/XSD.hs:1:1: error:
rdf4h-vocabulary > Exception when trying to run compile-time code:
rdf4h-vocabulary > ParseFailure "Parse failure: \n(line 7, column 2):\nunexpected Cannot resolve IRI: Scheme head: not enough input (Nothing,Nothing,\"\")\nexpecting subject resource"
rdf4h-vocabulary > CallStack (from HasCallStack):
rdf4h-vocabulary > error, called at src/Data/RDF/Vocabulary/Generator/VocabularyGenerator.hs:24:23 in rdf4h-vocabulary-generator-0.1.0.0-2J3xItsPFIeIMGirmv8qwN:Data.RDF.Vocabulary.Generator.VocabularyGenerator
rdf4h-vocabulary > Code: genVocabulary "resources/xsd.ttl"
I'll have a closer look if I have time, but for this ticket I think you can close it. Either it requires a fix to that repo or to create a tool along these lines.
from rdf4h.
@robstewart57 Do you think those packages should be integrated into rdf4h
or kept in a separate repository ?
from rdf4h.
@tonicebrian in your clone of rdf4h-vocabulary
, change resources/xsd.ttl
.
Change line 7 from:
<> rdfs:label "XSD Namespace Document";
to:
xsd: rdfs:label "XSD Namespace Document";
Then try compiling.
from rdf4h.
Do you think those packages should be integrated into rdf4h or kept in a separate repository ?
I've thought about that too. The author of the packages, @fabianmeyer , has previously indicated this would be fine.
The main issue I see is the added template-haskell
dependency rdf4h-vocabulary-generator
would bring into rdf4h
. But since stackage now stores pre-compiled packages, this is perhaps a lower cost to compile times it would have been in the past. It also depends on classy-prelude
, but I assume that could be removed if these two libraries are absorbed into the rdf4h
library.
Compiling the actual RDFS.hs
, XSD.hs
, SHACL.hs
etc modules takes ~10 seconds, so not a huge cost.
from rdf4h.
Hi @robstewart57 that solved the problem.
@koslambrou and @robstewart57 if you accept a suggestion, I think it would be a super good addition to rdf4h. First because coming myself from rdf4j I was expecting something similar here (or at least a clear sign pointing to those libraries). And if you are going to include them in the library, please unroll symbols from template haskell into regular Haskell source code files. When I was looking for a functionality like this one I was looking for autocomplete and to avoid silly typos when coding applications.
If I'm not able to check symbols we are again as blind as before when we could type the whole IRI in text.
from rdf4h.
@tonicebrian @koslambrou This has been implemented in the schema-vocab
branch with this commit: b3463e7
@tonicebrian when you build the rdf4h library now (on the schema-vocab
branch), it will create and compile some additional modules:
- Data.RDF.Vocabulary.DCTerms
- Data.RDF.Vocabulary.OWL
- Data.RDF.Vocabulary.RDF
- Data.RDF.Vocabulary.RDFS
- Data.RDF.Vocabulary.SHACL
- Data.RDF.Vocabulary.VANN
- Data.RDF.Vocabulary.XSD
Your IDE's auto-complete support should be able to find these modules. If you run the haddock tool you should also be able to generate HTML documentation for these Haskell modules that are generated at compile time. E.g. if using stack, then stack haddock
, which prints the filepath to the index.html
HTML file for rdf4h.
Adding more common schemas to rdf4h should just be a case of adding a Turtle schema file in the resources/
directory and creating a stub Haskell module in Data.RDF.Vocabulary
. Or you can also use the genVocabulary
Template Haskell function in your own application code.
Does this work for you?
from rdf4h.
Hey @robstewart57 yes, this works for me. If you could please add FOAF and SKOS to this first PR it would be super nice.
from rdf4h.
@tonicebrian done #110 .
from rdf4h.
Related Issues (20)
- Cannot use parseFile with RDF that does not have a base URI and URI without "http:"
- Invalid RDF format when writing to file
- Invalid blank node creation when using BNode or bnode HOT 1
- Use rdfs:comment string to generate documentation in genVocabulary
- Parser not handling correct turtle file HOT 5
- Easily compose operations such as addTriple, removeTriple, etc. HOT 3
- Base URI not detected with TurtleParser HOT 1
- Corner case property failure for query_match_spo
- Another corner case property failure for query_match_spo
- Can't override default prefixes in TurtleSerializer HOT 1
- TurtleSerializer baseUrl and prefix mappings effect HOT 8
- mkRdf using default prefixes HOT 5
- Build failure due to GHC option "-threaded" HOT 1
- Questions about Blank Nodes HOT 4
- Add a Namespace for schema.org HOT 2
- Exclude GPL hgal dependency HOT 10
- Aliased URI Not Properly Serialized
- Non-URI Nodes (TurtleSerializer)? HOT 2
- Bug: TurtleSerializer Does Not Properly Group Common Subjects HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rdf4h.