Skip to content

Commit 12a8103

Browse files
committed
version bump, renamed RML maps
1 parent 0dd6468 commit 12a8103

10 files changed

+38
-14
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*.pyc
88
*eggs*
99
*coverage
10+
logs*
1011
data*
1112
build*
1213
dist*

bibcat/ingesters/oai_pmh.py

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io
77
import logging
88
import os
9+
import time
910
try:
1011
from lxml import etree
1112
except ImportError:
@@ -388,6 +389,9 @@ def harvest(self, **kwargs):
388389
if deduplicator:
389390
deduplicator.run(self.processor.output,
390391
kwargs.get("dedup_classes"))
392+
logging.info(" processed {}, triples count {:,}".format(
393+
item_url,
394+
len(self.processor.output)))
391395
self.repo_graph += self.processor.output
392396
if 'out_file' in kwargs:
393397
with open(kwargs.get('out_file'), 'wb+') as fo:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

bibcat/maps/mods-to-bf.ttl

+8
Original file line numberDiff line numberDiff line change
@@ -640,4 +640,12 @@ bc:MODS2BIBFRAME_Item a rr:TriplesMap ;
640640
rr:objectMap [
641641
rr:reference "mods:originInfo/mods:dateIssued"
642642
]
643+
] ;
644+
645+
rr:predicateObjectMap [
646+
rr:predicate rdf:type ;
647+
rr:objectMap [
648+
rr:reference """mods:physicalDescription/mods:form[text()="image/tiff"]""" ;
649+
rr:constant bf:StillImage
650+
]
643651
] .
File renamed without changes.

bibcat/rml/processor.py

+24-13
Original file line numberDiff line numberDiff line change
@@ -891,18 +891,26 @@ class SPARQLBatchProcessor(Processor):
891891
in an attempt to reduce the time spent in the triplestore/network
892892
bottleneck"""
893893

894-
def __init__(self, rml_rules, triplestore_url):
894+
def __init__(self, rml_rules, triplestore_url=None, triplestore=None):
895895
super(SPARQLBatchProcessor, self).__init__(rml_rules)
896896
__set_prefix__()
897-
self.triplestore_url = triplestore_url
897+
if triplestore_url is not None:
898+
self.triplestore_url = triplestore_url
899+
elif triplestore is not None:
900+
self.triplestore = triplestore
898901

899902
def __get_bindings__(self, sparql):
900-
result = requests.post(
901-
self.triplestore_url,
902-
data={"query": sparql,
903-
"format": "json"})
904-
bindings = result.json().get("results").get("bindings")
905-
903+
bindings = []
904+
if self.triplestore_url is not None:
905+
result = requests.post(
906+
self.triplestore_url,
907+
data={"query": sparql,
908+
"format": "json"})
909+
bindings = result.json().get("results").get("bindings")
910+
elif self.triplestore is not None:
911+
result = self.triplestore.query(sparql)
912+
bindings = result.bindings
913+
906914
return bindings
907915

908916
def __construct_compound_query__(self, triple_map):
@@ -941,11 +949,14 @@ def execute(self, triple_map, **kwargs):
941949
iterator = str(triple_map.logicalSource.iterator)
942950
for binding in bindings:
943951
entity_dict = binding.get(iterator)
944-
raw_value = entity_dict.get('value')
945-
if entity_dict.get('type').startswith('bnode'):
946-
entity = rdflib.BNode(raw_value)
947-
else:
948-
entity = rdflib.URIRef(raw_value)
952+
if isinstance(entity_dict, rdflib.term.Node):
953+
entity = entity_dict
954+
elif isinstance(entity_dict, dict):
955+
raw_value = entity_dict.get('value')
956+
if entity_dict.get('type').startswith('bnode'):
957+
entity = rdflib.BNode(raw_value)
958+
else:
959+
entity = rdflib.URIRef(raw_value)
949960
if triple_map.subjectMap.class_ is not None:
950961
self.output.add(
951962
(entity,

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="bibcat",
9-
version="1.16.2",
9+
version="1.18.0",
1010
description="BIBCAT RDF Framework Application",
1111
author="KnowledgeLinks",
1212
author_email="knowledgelinks.io@gmail.com",

0 commit comments

Comments
 (0)