Lua ActiveRDF
Putting the Semantic Web on Lua

Overview

Lua ActiveRDF is a library for accessing RDF data from Lua programs. In fact, Lua ActiveRDF is a Lua version of ActiveRDF for Ruby.

Lua ActiveRDF allows you to rapidly create semantic web applications.

Lua ActiveRDF gives you a Domain Specific Language (DSL) for your RDF model: you can address RDF resources, classes, properties, etc. programmatically, without queries.

Lua ActiveRDF can be used with various RDF stores, adapters to other stores can be written very easily. SPARQL and RDFLite adapters are available.

Lua ActiveRDF is free software and uses the same license as Lua 5.1.

Status

Current version is 0.1 and works with Lua 5.1.

Examples

   Create and edit people
-- we load activerdf
rdf = require 'activerdf'

-- we add an existing SPARQL database as datasource
url = 'http://tecweb08.tecweb.inf.puc-rio.br:8890/sparql'
rdf.ConnectionPool.add_data_source { type = 'sparql', engine = 'virtuoso', url = url }

-- we register a short-hand notation for the namespace used in this test data
rdf.Namespace.register ( 'test', 'http://activerdf.luaforge.net/test/' )

-- now we can access all RDF properties of a person as Ruby attributes:
john = rdf.RDFS.Resource.new 'http://activerdf.luaforge.net/test/john'
print ( john.test.age )
print ( john.test.eye )
table.foreach ( john.rdf.type, print )

-- now we construct Ruby classes for the currently existing RDFS classes
rdf.ObjectManager.construct_classes()

-- and we can use these classes
bob = rdf.TEST.Person.new 'http://activerdf.luaforge.net/test/bob'

-- we cannot change anything, since SPARQL endpoints have just read-only access
   Find resources
rdf = require 'activerdf'

-- we add an existing SPARQL database as datasource
url = 'http://tecweb08.tecweb.inf.puc-rio.br:8890/sparql'
rdf.ConnectionPool.add_data_source { type = 'sparql', engine = 'virtuoso', url = url }

-- we register a short-hand notation for the namespace used in this test data
rdf.Namespace.register ( 'test', 'http://activerdf.luaforge.net/test/' )

rdf.ObjectManager.construct_classes()

all_people = rdf.TEST.Person:find_all()
all_resources = rdf.RDFS.Resource:find_all()

-- print all the people, and their friends
for _, person in ipairs(all_people) do
print ( tostring(person.name) .. " has " .. tostring(person.test.eye) .." eyes" )
end

-- find all people aged 27
almost_thirties = rdf.TEST.Person:find_by_test().age(27)
print ( "the following people are almost thirty: " .. almost_thirties )

Download

Lua ActiveRDF can be downloaded from its LuaForge page.

You can also install  Lua ActiveRDF using LuaRocks (not available yet):

luarocks install activerdf

Dependencies

      Lua ActiveRDF Core      Lua RDFLite Adapter      Lua Sparql Adapter

Credits

Lua ActiveRDF 0.1 was implemented by Mauricio Henrique de Souza Bomfim, oriented by the prof. Daniel Schwabe and is strongly based on ActiveRDF for Ruby.

Contact us

For more information please contact us. Comments are welcome!

You can also reach other Lua ActiveRDF developers and users on the Kepler Project mailing list.

Valid XHTML 1.0!