def get_information(self): """ Get the information from triple store """ query = """ PREFIX es: <http://www.semanticweb.org/ontologies/2018/Software_Engineering/> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT DISTINCT ?title ?curriculum WHERE { es:Computing_Foundations dc:title ?title . es:Computing_Foundations rdfs:subClassOf ?restriction . ?restriction owl:onProperty es:isKnowledgeAreaOf . ?restriction owl:someValuesFrom ?curriculum_url . ?curriculum_url dc:title ?curriculum } """ result = Query.run(Sesame.endpoint, query) return result[0]
def get_disciplines(self, predicate, obj): """ Get the data from triple store. """ query = """ PREFIX pp: <http://www.semanticweb.org/ontologies/2018/Pedagogical_Project/> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT DISTINCT ?disciplines ?code ?title ?description ?type ?semester ?core_content WHERE { ?disciplines %s %s . ?disciplines dc:title ?title . OPTIONAL {?disciplines dc:description ?description .} OPTIONAL {?disciplines pp:code ?code .} OPTIONAL {?disciplines pp:hasType ?type_uri .} OPTIONAL {?type_uri dc:title ?type .} OPTIONAL {?disciplines pp:isInTheFlowOf ?semester_uri .} OPTIONAL {?semester_uri dc:title ?semester .} OPTIONAL {?disciplines pp:isPartOf ?core_content_uri} OPTIONAL {?core_content_uri dc:title ?core_content} } """ % (predicate, obj) result = Query.run(Sesame.endpoint, query) disciplines = [] for discipline in result: obj = Discipline(uri=discipline['disciplines']['value'], title=discipline['title']['value'], code=discipline['code']['value'], description=discipline['description']['value'], classification=discipline['type']['value'], semester=discipline['semester']['value'], core_content=discipline['core_content']['value']) disciplines.append(obj) return disciplines
def get_contents(cls, discipline_uri): """ Get content disciplines from triple store. """ query = """ PREFIX pp: <http://www.semanticweb.org/ontologies/2018/Pedagogical_Project/> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT DISTINCT ?content_uri ?title ?topic_uri ?topic ?knowledge_uri ?knowledge WHERE { <%s> pp:hasContent ?content_uri . ?content_uri dc:title ?title . ?content_uri rdfs:subClassOf ?topic_uri . ?topic_uri dc:title ?topic . ?topic_uri rdfs:subClassOf ?knowledge_uri . ?knowledge_uri dc:title ?knowledge } """ % (discipline_uri) result = Query.run(Sesame.endpoint, query) contents = [] for content in result: knowledge = Knowledge(uri=content['knowledge_uri']['value'], title=content['knowledge']['value']) topic = Topic(uri=content['topic_uri']['value'], title=content['topic']['value']) subtopic = Subtopic(uri=content['content_uri']['value'], title=content['title']['value'], topic=topic, knowledge=knowledge) contents.append(subtopic) return contents
def get_disciplines(self): """ Get all discipline of multidisciplinary content. """ query = """ PREFIX pp: <http://www.semanticweb.org/ontologies/2018/Pedagogical_Project/> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT DISTINCT ?title WHERE { ?disciplines pp:isPartOf pp:Multidisciplinary ; dc:title ?title } """ result = Query.run(Sesame.endpoint, query) disciplines = [] for discipline in result: discipline = Discipline(discipline['title']['value']) disciplines.append(discipline) return disciplines
SELECT DISTINCT ?resumo WHERE { dbr:Software_engineering dbo:abstract ?resumo FILTER (lang(?resumo) = 'pt') } """ query_unb = """ SELECT DISTINCT ?sigla ?nome ?cidade ?pais ?estado ?site ?resumo WHERE { dbr:University_of_Brasília dbp:sigla ?sigla ; rdfs:label ?nome ; foaf:homepage ?site ; dbo:abstract ?resumo ; dbo:city ?city . ?city rdfs:label ?cidade . dbr:University_of_Brasília dbo:country ?country . ?country rdfs:label ?pais . dbr:University_of_Brasília dbo:state ?state . ?state rdfs:label ?estado . FILTER (lang(?resumo) = 'pt') FILTER (lang(?cidade) = 'pt') FILTER (lang(?pais) = 'pt') FILTER (lang(?estado) = 'pt') FILTER (lang(?nome) = 'pt') } """ print(Query.run("http://dbpedia.org/sparql", query_unb))