예제 #1
0
 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)
예제 #2
0
 def doQuery(self, graph=None, query=None):
     res = None
     try:
         RDFLIBLOCK.acquire()
         res = list(graph.query(query))
     finally:
         RDFLIBLOCK.release()
     return res
예제 #3
0
 def doQuery(self,graph=None,query=None):
     res = None
     try:
         RDFLIBLOCK.acquire()
         res = list(graph.query(query))
     finally:
         RDFLIBLOCK.release()
     return res    
예제 #4
0
 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
예제 #5
0
    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
예제 #6
0
 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)
예제 #7
0
 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)
예제 #8
0
 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)