Code Monkey home page Code Monkey logo

rdf4h's Introduction

RDF For Haskell

Build Status

rdf4h is a library for working with RDF in Haskell. At present it includes parsers and serializers for RDF in the N-Triples and Turtle formats, and parsing support for RDF/XML. It provides abilities such as querying for triples containing a particular subject, predicate, or object, or selecting triples that satisfy an arbitrary predicate function.

Installation

Once the Haskell platform has been installed, simply:

$ cabal update
$ cabal install rdf4h

Usage

The rdf4h library is split in to two parts.

  • Data.RDF defines the RDF, RdfSerializer and RdfParser type classes. It also provides an API for RDF graph inspection.
  • Text.RDF.RDF4H.* provides the parsers and serializers for supported RDF formats.

Example

{-# LANGUAGE OverloadedStrings #-}

import Data.RDF
import Data.RDF.TriplesGraph
import Text.RDF.RDF4H.NTriplesParser

rdfGraph1 :: IO TriplesGraph
rdfGraph1 = fmap fromEither (parseFile NTriplesParser "test1.nt")

rdfGraph2 :: IO TriplesGraph
rdfGraph2 = fmap fromEither (parseFile NTriplesParser "test2.nt")

example :: IO ()
example = do
  g1 <- rdfGraph1
  g2 <- rdfGraph2
  let node1 = lnode $ PlainL "foo"
  putStrLn $ "Subjects of g1: " ++ show (map subjectOf (triplesOf g1))
  putStrLn $ "RDF contains literal 'foo': " ++ show (rdfContainsNode g1 node1)
  putStrLn $ "Isomorphism test: " ++ show (isIsomorphic g1 g2)
  putStrLn $ "Unsorted triples: " ++ show (triplesOf g2)
  putStrLn $ "Sorted triples: "   ++ show ((sortTriples . triplesOf) g2)
  putStrLn $ "Query: " ++ show (query g1 Nothing Nothing (Just node1))

TODOs

  • RDF/XML Serialization; Add RdfParser instance for XmlParser
  • Data.RDF API to match that of the Model class in the Jena framework (Java)

Issues

Please use the GitHub issue tracker to report any bugs you might find. New contributors are most welcome, and pull requests will be favourably received.

Related Haskell Packages

  • hsparql is a DSL for programmatic creation and execution of SPARQL queries. It makes use of the RDF type class in rdf4h, allowing the two packages to be combined easily.
  • swish is a toolkit for RDF inference and for implementing RDF file processors. It explores Haskell as "a scripting language for the semantic web".

rdf4h's People

Contributors

amccausl avatar cordawyn avatar eukaryote avatar robstewart57 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.