triple_store.rb revision 0ce564ede3f34734b5b3ca6c5e982a15bf818b6d
require 'rdf'
# A triple store of relational statements (Subject, Predicate, Object)
#
# Author: Daniel Couto Vale <danielvale@uni-bremen.de>
#
# A map (predicate x object) -> subject
# A map (subject x object) -> predicate
# A map (subject x predicate) -> object
# Constructs a statement store from an rdf file
#
# path_name - the path name of the rdf file to load
#
statements = []
end && 0
return TripleStore.new statements
end
# Constructor
#
# statements - a list of statements
#
statements.each do |statement|
# Read statement components
# Map subject
# Map predicate
# Map object
end
end
# Returns a list with all subjects for a given object-predicate pair
#
# * *Args* :
# * - +predicate+ -> a predicate
# * - +object+ -> a range
# * *Returns* :
# * - the list of subjects for given predicate and range
end
# Returns a list with all predicates for a given subject-object pair
#
# * *Args* :
# * - +subject+ -> a domain
# * - +object+ -> a range
# * *Returns* :
# * - the list of predicates for given domain and range
return entities(@predicateMap[subject], object)
end
# Returns a list with all objects for a given subject-predicate pair
#
# * *Args* :
# * - +subject+ -> a domain
# * - +predicate+ -> a relation
# * *Returns* :
# * - the list of objects for given domain and relation
end
# Lists the entities with the given restrictions
#
# * *Args* :
# * - +hash+ -> a hash of arrays
# * - +key+ -> a key of the array
# * *Returns* :
# * - the indicated entity array if it exists
# * - an empty array otherwise
if !hash
return Array.new
elsif !hash[key]
return Array.new
else
end
end
# Maps an entity with two keys
#
# * *Args* :
# * - +map+ -> a hash of hashes of arrays
# * - +key1+ -> a key to a hash of arrays
# * - +key2+ -> a key to an array
# * - +entity+ -> an entity to be added to the array
# * *Returns* :
# * - the updated map containing the entity
end
end
return map
end
end