def outputCSVtypes(self, file): atticfilter = "" if self.excludeAttic: atticfilter = "FILTER NOT EXISTS {?term schema:isPartOf <http://attic.schema.org>}." query = ('''select ?term where { ?term a ?type. BIND(STR(?term) AS ?strVal) FILTER NOT EXISTS {?term a rdf:Property}. FILTER(STRLEN(?strVal) >= 18 && SUBSTR(?strVal, 1, 18) = "http://schema.org/"). %s } ORDER BY ?term ''') % atticfilter try: RDFLIBLOCK.acquire() types = list(self.queryGraph.query(query)) finally: RDFLIBLOCK.release() #log.info( "Types: %s" % len(types)) self.type2CSV(header=True, out=file) for t in types: self.type2CSV(term=t.term, header=False, out=file, graph=self.queryGraph)
def doQuery(self, graph=None, query=None): res = None try: RDFLIBLOCK.acquire() res = list(graph.query(query)) finally: RDFLIBLOCK.release() return res
def doQuery(self,graph=None,query=None): res = None try: RDFLIBLOCK.acquire() res = list(graph.query(query)) finally: RDFLIBLOCK.release() return res
def graphValueToCSV(self, subject=None, predicate= None, object= None, graph=None): ret = "" try: RDFLIBLOCK.acquire() ret = str(graph.value(subject=subject,predicate=predicate,object=object)) finally: RDFLIBLOCK.release() if ret == None or ret == "None": ret = "" return ret
def graphValueToCSV(self, subject=None, predicate=None, object=None, graph=None): ret = "" try: RDFLIBLOCK.acquire() ret = str( graph.value(subject=subject, predicate=predicate, object=object)) finally: RDFLIBLOCK.release() if ret == None or ret == "None": ret = "" return ret
def outputCSVtypes(self,file): atticfilter = "" if self.excludeAttic: atticfilter = "FILTER NOT EXISTS {?term schema:isPartOf <%s>}." % self.attic query= ('''select ?term where { ?term a ?type. FILTER NOT EXISTS {?term a rdf:Property}. FILTER (strstarts(str(?term),'%s')). %s } ORDER BY ?term ''') % (api.SdoConfig.vocabUri(),atticfilter) try: RDFLIBLOCK.acquire() types = list(self.queryGraph.query(query)) finally: RDFLIBLOCK.release() #log.info( "Types: %s" % len(types)) self.type2CSV(header=True,out=file) for t in types: self.type2CSV(term=t.term,header=False,out=file,graph=self.queryGraph)
def outputCSVtypes(self,file): atticfilter = "" if self.excludeAttic: atticfilter = "FILTER NOT EXISTS {?term schema:isPartOf <http://attic.schema.org>}." query= ('''select ?term where { ?term a ?type. BIND(STR(?term) AS ?strVal) FILTER NOT EXISTS {?term a rdf:Property}. FILTER(STRLEN(?strVal) >= 18 && SUBSTR(?strVal, 1, 18) = "http://schema.org/"). %s } ORDER BY ?term ''') % atticfilter try: RDFLIBLOCK.acquire() types = list(self.queryGraph.query(query)) finally: RDFLIBLOCK.release() #log.info( "Types: %s" % len(types)) self.type2CSV(header=True,out=file) for t in types: self.type2CSV(term=t.term,header=False,out=file,graph=self.queryGraph)
def outputCSVtypes(self, file): atticfilter = "" if self.excludeAttic: atticfilter = "FILTER NOT EXISTS {?term schema:isPartOf <%s>}." % self.attic query = ('''select ?term where { ?term a ?type. FILTER NOT EXISTS {?term a rdf:Property}. FILTER (strstarts(str(?term),'%s')). %s } ORDER BY ?term ''') % (api.SdoConfig.vocabUri(), atticfilter) try: RDFLIBLOCK.acquire() types = list(self.queryGraph.query(query)) finally: RDFLIBLOCK.release() #log.info( "Types: %s" % len(types)) self.type2CSV(header=True, out=file) for t in types: self.type2CSV(term=t.term, header=False, out=file, graph=self.queryGraph)