class Document(Entity): rdf_type = roar.Document identifier = rdfSingle(schema.identifier) language = rdfSingle(schema.isInLanguage) inventoryNumber = rdfSingle(saa.inventoryNumber) sectionNumber = rdfSingle(saa.sectionNumber) sourceReference = rdfSingle(saa.sourceReference) urlScan = rdfMultiple(saa.urlScan) label = rdfMultiple(RDFS.label) description = rdfSingle(saa.description) mentionsRegistered = rdfMultiple(saa.mentionsRegistered) mentionsLocation = rdfMultiple(saa.mentionsLocation, range_type=saa.Location) mentionsAddress = rdfSingle(saa.mentionsAddress) mentionsStreet = rdfSingle(saa.mentionsStreet) mentionsOriginalStreet = rdfSingle(saa.mentionsOriginalStreet) mentionsNeighbourhoodCode = rdfSingle(saa.mentionsNeighbourhoodCode) mentionsNeihbourhoodNumber = rdfSingle(saa.mentionsNeihbourhoodNumber) mentionsStreetKlein = rdfSingle(saa.mentionsStreetKlein) mentionsStreetExtra = rdfSingle(saa.mentionsStreetExtra) mentionsOccupation = rdfSingle(saa.mentionsOccupation) onScan = rdfMultiple(roar.onScan)
class CategoryCode(rdfSubject): rdf_type = schema.CategoryCode inCodeSet = rdfSingle(schema.inCodeSet, range_type=schema.CategoryCodeSet) codeValue = rdfSingle(schema.codeValue) label = rdfMultiple(RDFS.label) name = rdfMultiple(schema.name)
class Location(rdfSubject): rdf_type = saa.Location isInRecord = rdfSingle(saa.isInRecord) label = rdfMultiple(RDFS.label) altLabel = rdfMultiple(skos.altLabel) sameAs = rdfMultiple(OWL.sameAs)
class Derivation(rdfSubject): rdf_type = prov.Derivation label = rdfMultiple(RDFS.label) comment = rdfMultiple(RDFS.comment) hadActivity = rdfSingle(prov.hadActivity) entity = rdfMultiple(prov.entity)
class Thing(rdfSubject): rdf_type = None label = rdfMultiple(RDFS.label) comment = rdfSingle(RDFS.comment) name = rdfMultiple(schema.name) description = rdfSingle(schema.description) sameAs = rdfMultiple(OWL.sameAs) isPartOf = rdfSingle(schema.isPartOf) license = rdfSingle(schema.license) publisher = rdfSingle(schema.publisher) mainEntityOfPage = rdfSingle(schema.mainEntityOfPage) dateCreated = rdfSingle(schema.dateCreated) dateModified = rdfSingle(schema.dateModified) subjectOf = rdfMultiple(schema.subjectOf) value = rdfSingle(RDF.value) startDate = rdfSingle(schema.startDate) hasTimeStamp = rdfSingle(sem.hasTimeStamp) hasBeginTimeStamp = rdfSingle(sem.hasBeginTimeStamp) hasEndTimeStamp = rdfSingle(sem.hasEndTimeStamp) hasEarliestBeginTimeStamp = rdfSingle(sem.hasEarliestBeginTimeStamp) hasLatestBeginTimeStamp = rdfSingle(sem.hasLatestBeginTimeStamp) hasEarliestEndTimeStamp = rdfSingle(sem.hasEarliestEndTimeStamp) hasLatestEndTimeStamp = rdfSingle(sem.hasLatestEndTimeStamp)
class Role(Thing): rdf_type = schema.Role author = rdfMultiple(schema.author) about = rdfSingle(schema.about) roleName = rdfSingle(schema.roleName) publishedBy = rdfSingle(schema.publishedBy) hasName = rdfMultiple(pnv.hasName)
class Entity(rdfSubject): rdf_type = prov.Entity label = rdfMultiple(RDFS.label) comment = rdfMultiple(RDFS.comment) wasDerivedFrom = rdfMultiple(prov.wasDerivedFrom) qualifiedDerivation = rdfSingle(prov.qualifiedDerivation, range_type=prov.Derivation) partOf = rdfSingle(saa.partOf) hasParts = rdfMultiple(saa.hasParts) code = rdfSingle(saa.code) identifier = rdfSingle(saa.identifier) title = rdfSingle(saa.title) date = rdfSingle(saa.date) hasTimeStamp = rdfSingle(sem.hasTimeStamp) hasBeginTimeStamp = rdfSingle(sem.hasBeginTimeStamp) hasEndTimeStamp = rdfSingle(sem.hasEndTimeStamp) hasEarliestBeginTimeStamp = rdfSingle(sem.hasEarliestBeginTimeStamp) hasLatestBeginTimeStamp = rdfSingle(sem.hasLatestBeginTimeStamp) hasEarliestEndTimeStamp = rdfSingle(sem.hasEarliestEndTimeStamp) hasLatestEndTimeStamp = rdfSingle(sem.hasLatestEndTimeStamp)
class Event(rdfsSubject): rdf_type = bio.Event, sem.Event label = rdfMultiple(RDFS.label) date = rdfSingle(bio.date) followingEvent = rdfSingle(bio.followingEvent) precedingEvent = rdfSingle(bio.precedingEvent) hasTimeStamp = rdfSingle(sem.hasTimeStamp) hasBeginTimeStamp = rdfSingle(sem.hasBeginTimeStamp) hasEndTimeStamp = rdfSingle(sem.hasEndTimeStamp) hasEarliestBeginTimeStamp = rdfSingle(sem.hasEarliestBeginTimeStamp) hasLatestBeginTimeStamp = rdfSingle(sem.hasLatestBeginTimeStamp) hasEarliestEndTimeStamp = rdfSingle(sem.hasEarliestEndTimeStamp) hasLatestEndTimeStamp = rdfSingle(sem.hasLatestEndTimeStamp) place = rdfSingle(bio.place) # multi-predicates? witness = rdfMultiple(bio.witness) spectator = rdfMultiple(bio.spectator) parent = rdfMultiple(bio.parent) hasActor = rdfMultiple(sem.hasActor, range_type=sem.Role) comment = rdfSingle(RDFS.comment)
class OccupationObservation(Entity): rdf_type = roar.OccupationObservation label = rdfMultiple(RDFS.label) name = rdfMultiple(schema.name) occupationalCategory = rdfMultiple(schema.occupationalCategory, range_type=schema.CategoryCode)
class Occupation(rdfSubject): rdf_type = schema.Occupation label = rdfMultiple(RDFS.label) name = rdfMultiple(schema.name) occupationalCategory = rdfMultiple(schema.occupationalCategory, range_type=schema.CategoryCode)
class Film(rdfSubject): """DBPedia films""" rdf_type = DBPO.Film #title = rdfMultiple(RDFS.label) title = rdfLocale(RDFS.label, 'en') frtitle = rdfLocale(RDFS.label, 'fr') subject = rdfMultiple(DCTERMS.subject) actor = rdfMultiple(DBPO.starring, range_type=UMBEL.Actor)
class VoidDataset(rdfSubject): rdf_type = void.Dataset subset = rdfMultiple(void.subset) title = rdfSingle(dcterms.title) description = rdfSingle(dcterms.description) label = rdfMultiple(RDFS.label)
class Activity(rdfSubject): rdf_type = prov.Activity label = rdfMultiple(RDFS.label) comment = rdfMultiple(RDFS.comment) wasAssociatedWith = rdfMultiple(prov.wasAssociatedWith, range_type=prov.Agent) qualifiedAssociation = rdfSingle(prov.qualifiedAssociation, range_type=prov.Association)
class Concept(rdfSubject): rdf_type = skos.Concept prefLabel = rdfMultiple(skos.prefLabel) broader = rdfMultiple(skos.broader) narrower = rdfMultiple(skos.narrower) relatedMatch = rdfMultiple(skos.relatedMatch)
class Concept(Entity): rdf_type = SKOS.Concept prefLabel = rdfMultiple(SKOS.prefLabel) note = rdfMultiple(SKOS.note) related = rdfMultiple(SKOS.related) broader = rdfMultiple(SKOS.broader) narrower = rdfMultiple(SKOS.narrower)
class Document(rdfsSubject): rdf_type = BIBO.Document title = rdfSingle(DC['title']) alt_titles = rdfMultiple(DC.alt) date = rdfSingle(DC.date) issued = rdfSingle(DC.issued) modified = rdfSingle(DC.modified) creators = rdfMultiple(DC.creator) authorList = rdfMultiple(BIBO.authorList) subjects = rdfMultiple(DC.subject, range_type=SKOS.Concept)
class Event(Thing): rdf_type = sem.Event hasPlace = rdfMultiple(sem.hasPlace) hasActor = rdfMultiple(sem.hasActor) eventType = rdfMultiple(sem.eventType) precedingEvent = rdfMultiple(bio.precedingEvent) followingEvent = rdfMultiple(bio.followingEvent)
class Entity(rdfSubject): rdf_type = URIRef('urn:entity') additionalType = rdfSingle(schema.additionalType) label = rdfMultiple(RDFS.label) name = rdfMultiple(schema.name) alternateName = rdfMultiple(schema.alternateName) description = rdfMultiple(schema.description) mainEntityOfPage = rdfSingle(schema.mainEntityOfPage) sameAs = rdfMultiple(OWL.sameAs) disambiguatingDescription = rdfMultiple(schema.disambiguatingDescription) keywords = rdfMultiple(schema.keywords) depiction = rdfSingle(foaf.depiction) subjectOf = rdfMultiple(schema.subjectOf) about = rdfMultiple(schema.about) url = rdfSingle(schema.url) inDataset = rdfSingle(void.inDataset) hasTimeStamp = rdfSingle(sem.hasTimeStamp) hasEarliestBeginTimeStamp = rdfSingle(sem.hasEarliestBeginTimeStamp) hasLatestEndTimeStamp = rdfSingle(sem.hasLatestEndTimeStamp)
class Project(rdfSubject): rdf_type = DOAP.Project name = rdfSingle(DOAP.name) created = rdfSingle(DOAP.created) homepage = rdfSingle(DOAP.homepage) shortdesc = rdfMultiple(DOAP.shortdesc) releases = rdfMultiple(DOAP.release, range_type=DOAP.Version) language = rdfSingle( DOAP['programming-language']) # because of the hyphen we can't use # DOAP.programming-language maintainer = rdfSingle(DOAP.maintainer, range_type=FOAF.Person)
class Linkset(Dataset): """Linkset class from the void vocabulary. Indicate at least: * target (2..*) * linkPredicate (property used to link entities (e.g. owl:sameAs)) """ rdf_type = void.Linkset, schema.Dataset target = rdfMultiple(void.target, range_type=void.Dataset) linkPredicate = rdfMultiple(void.linkPredicate, range_type=URIRef)
class Record(rdfSubject): rdf_type = ga.IndexOpBegraafregisters identifier = rdfSingle(saa.identifier) sourceReference = rdfSingle(saa.sourceReference) inventoryNumber = rdfSingle(saa.inventoryNumber) urlScan = rdfSingle(saa.urlScan) mentionsRegisteredName = rdfMultiple(saa.mentionsRegisteredName) mentionsBuriedName = rdfMultiple(saa.mentionsBuriedName) relationInformation = rdfSingle(saa.relationInformation) cemetery = rdfSingle(saa.cemetery) burialDate = rdfSingle(saa.burialDate)
class CreativeWork(Entity): rdf_type = schema.CreativeWork publication = rdfSingle(schema.publication) author = rdfMultiple(schema.author) text = rdfMultiple(schema.text) mainEntity = rdfSingle(schema.mainEntity) isPartOf = rdfMultiple(schema.isPartOf) isRelatedTo = rdfMultiple(schema.isRelatedTo)
class Document(Entity): rdf_type = roar.Document, edm.ProvidedCHO identifier = rdfSingle(schema.identifier) language = rdfSingle(schema.isInLanguage) label = rdfMultiple(RDFS.label) onScan = rdfMultiple(roar.onScan) items = rdfList(AS.items) # rdf:Collection prev = rdfSingle(AS.prev) next = rdfSingle(AS.next)
class Book(Thing): rdf_type = schema.Book author = rdfMultiple(schema.author) inLanguage = rdfMultiple(schema.inLanguage) publication = rdfSingle(schema.publication) bibliographicFormat = rdfSingle(kbdef.bibliographicFormat) hasCollationalFormula = rdfSingle(kbdef.hasCollationalFormula) about = rdfMultiple(schema.about) numberOfPages = rdfSingle(schema.numberOfPages) workExample = rdfMultiple(schema.workExample)
class Event(Entity): rdf_type = sem.Event, bio.Event place = rdfSingle(bio.place) principal = rdfSingle(bio.principal) partner = rdfMultiple(bio.partner)
class Entity(rdfSubject): rdf_type = prov.Entity label = rdfMultiple(RDFS.label) comment = rdfMultiple(RDFS.comment) wasDerivedFrom = rdfMultiple(prov.wasDerivedFrom) qualifiedDerivation = rdfSingle(prov.qualifiedDerivation, range_type=prov.Derivation) inDataset = rdfSingle(void.inDataset) hasLocation = rdfMultiple(roar.hasLocation) documentedIn = rdfSingle(roar.documentedIn) identifier = rdfSingle(schema.identifier)
class Entity(rdfSubject): rdf_type = prov.Entity locationInDocument = rdfSingle(roar.locationInDocument) name = rdfMultiple(schema.name) url = rdfSingle(schema.url)
class LocationObservation(Observation): rdf_type = roar.LocationObservation hasPerson = rdfMultiple(roar.hasPerson) address = rdfSingle(schema.address) geoWithin = rdfSingle(schema.geoWithin)
class Company(rdfSubject): rdf_type = ov.Company symbol = rdfSingle(ov.symbol, ) cik = rdfSingle(ov.secCik, 'cik') companyName = rdfSingle(ov.companyName, 'companyName') stockDescription = rdfSingle(ov.stockDescription, 'stockDescription') stock = rdfMultiple(ov.hasIssue)
class Entity(rdfSubject): rdf_type = URIRef('urn:entity') label = rdfMultiple(RDFS.label) name = rdfMultiple(schema.name) url = rdfSingle(schema.url) hasGeometry = rdfSingle(geo.hasGeometry) startDate = rdfSingle(schema.startDate) hasTimeStamp = rdfSingle(sem.hasTimeStamp) hasBeginTimeStamp = rdfSingle(sem.hasBeginTimeStamp) hasEndTimeStamp = rdfSingle(sem.hasEndTimeStamp) hasEarliestBeginTimeStamp = rdfSingle(sem.hasEarliestBeginTimeStamp) hasLatestBeginTimeStamp = rdfSingle(sem.hasLatestBeginTimeStamp) hasEarliestEndTimeStamp = rdfSingle(sem.hasEarliestEndTimeStamp) hasLatestEndTimeStamp = rdfSingle(sem.hasLatestEndTimeStamp)
def test_addBNodeKnowsM(): Person.knows = rdfalchemy.rdfMultiple( FOAF.knowsM, range_type=FOAF.Person) mapper() p1 = Person(first="PhilipM") p2 = Person(last="Cooper", first="Ben") p3 = Person(last="Cooper", first="Matt") p1.knows = [p2, p3] p1 = Person.get_by(first="PhilipM") log.info("db len is %s" % len(Person.db)) assert len(p1.knows) == 2 del p1
def test_addBNodeKnowsM(): Person.knows = rdfalchemy.rdfMultiple(FOAF.knows, range_type=FOAF.Person) p1 = Person.get_by(first="Philip") p2 = Person(last="Cooper", first="Ben") p3 = Person(last="Cooper", first="Matt") assert len(Person.db) == 9 p1.knows = [p2, p3] print len(Person.db) assert len(Person.db) == 11 del p1.knows print len(Person.db) assert len(Person.db) == 3
log = logging.getLogger('rdfalchemy') if not log.handlers: log.addHandler(logging.StreamHandler()) #log.setLevel(10) Person.db = ConjunctiveGraph() def test_start(): assert len(Person.db) == 0 Person(last="Cooper") assert len(Person.db) == 2 Person.m = rdfalchemy.rdfMultiple(FOAF.multi) Person.l = rdfalchemy.rdfList(FOAF.list) Person.c = rdfalchemy.rdfContainer(FOAF.seq) def test_multi(): p = Person.ClassInstances().next() p.m = [1, 2.2, 0, 'a', '', 'c'] assert len(Person.db) == 8 p.m = ['a', 'b', 'c'] assert len(Person.db) == 5 def test_list(): # set and reset a list
import rdfalchemy from rdfalchemy.samples.doap import FOAF from rdfalchemy.samples.foaf import Person from rdfalchemy.orm import mapper from rdflib import ConjunctiveGraph import logging log = logging.getLogger('rdfalchemy') if not log.handlers: log.addHandler(logging.StreamHandler()) #log.setLevel(10) Person.db = ConjunctiveGraph() Person.knows = rdfalchemy.rdfMultiple(FOAF.knows, range_type=FOAF.Person) def test_start(): assert len(Person.db) == 0 p = Person(last="Cooper", first="Philip") assert len(Person.db) == 3 del p def test_addBNodeKnowsL(): Person.knows = rdfalchemy.rdfList(FOAF.knows, range_type=FOAF.Person) mapper() p1 = Person.get_by(first="Philip") p2 = Person(last="Cooper", first="Ben") p3 = Person(last="Cooper", first="Matt") assert len(Person.db) == 9
import rdfalchemy from rdfalchemy.rdfSubject import rdfSubject from rdfalchemy.descriptors import rdfLocale from rdfalchemy.samples.doap import DOAP, Project import platform if platform.system() == "Java": from nose import SkipTest raise SkipTest("Skipping, Java - Python unicode conflict") rdfSubject.db.parse("rdfalchemy/samples/schema/doap.rdf") p = Project(DOAP.SVNRepository) Project.ls = rdfalchemy.rdfSingle(rdfalchemy.RDFS.label, cacheName="ls") Project.lm = rdfalchemy.rdfMultiple(rdfalchemy.RDFS.label, cacheName="lm") Project.len = rdfLocale(rdfalchemy.RDFS.label, "en") Project.les = rdfLocale(rdfalchemy.RDFS.label, "es") Project.lfr = rdfLocale(rdfalchemy.RDFS.label, "fr") def en_es_test(): assert p.len == u"Subversion Repository", p.len assert p.les == u"Repositorio Subversion" assert p.lfr == u"D\xe9p\xf4t Subversion" # unkown resp print(repr(p.ls)) print(repr(p.lm)) print(repr(p.len))