pyLodStorage 0.4.4__tar.gz → 0.4.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pylodstorage-0.4.4/pylodstorage.egg-info → pylodstorage-0.4.6}/PKG-INFO +1 -1
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/trulytabular.py +8 -6
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/version.py +2 -2
- {pylodstorage-0.4.4 → pylodstorage-0.4.6/pylodstorage.egg-info}/PKG-INFO +1 -1
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/LICENSE +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/README.md +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/__init__.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/csv.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/entity.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/jsonable.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/jsonpicklemixin.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/lod.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/mwTable.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/plot.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/query.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/querymain.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/sample.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/schema.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/sparql.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/sql.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/storageconfig.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/tabulateCounter.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/uml.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/xml.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/lodstorage/yamlablemixin.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/pylodstorage.egg-info/SOURCES.txt +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/pylodstorage.egg-info/dependency_links.txt +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/pylodstorage.egg-info/entry_points.txt +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/pylodstorage.egg-info/requires.txt +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/pylodstorage.egg-info/top_level.txt +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/sampledata/__init__.py +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/sampledata/endpoints.yaml +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/sampledata/formats.yaml +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/sampledata/got.yaml +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/sampledata/queries.yaml +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/sampledata/scholia.yaml +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/sampledata/trulytabular.yaml +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/sampledata/wf.yaml +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/sampledata/wikidata.yaml +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/setup.cfg +0 -0
- {pylodstorage-0.4.4 → pylodstorage-0.4.6}/setup.py +0 -0
|
@@ -323,7 +323,7 @@ class TrulyTabular(object):
|
|
|
323
323
|
checks "how tabular" a query based on a list of properties of an itemclass is
|
|
324
324
|
'''
|
|
325
325
|
|
|
326
|
-
def __init__(self, itemQid, propertyLabels:list=[],propertyIds:list=[],where:str=None,endpointConf=None,lang="en",debug=False):
|
|
326
|
+
def __init__(self, itemQid, propertyLabels:list=[],propertyIds:list=[],subclassPredicate="wdt:P31",where:str=None,endpointConf=None,lang="en",debug=False):
|
|
327
327
|
'''
|
|
328
328
|
Constructor
|
|
329
329
|
|
|
@@ -331,6 +331,7 @@ class TrulyTabular(object):
|
|
|
331
331
|
itemQid(str): wikidata id of the type to analyze
|
|
332
332
|
propertyLabels(list): a list of labels of properties to be considered
|
|
333
333
|
propertyIds(list): a list of ids of properties to be considered
|
|
334
|
+
subclassPredicate(str): the subclass Predicate to use
|
|
334
335
|
where(str): extra where clause for instance selection (if any)
|
|
335
336
|
endpoint(str): the url of the SPARQL endpoint to be used
|
|
336
337
|
'''
|
|
@@ -341,6 +342,7 @@ class TrulyTabular(object):
|
|
|
341
342
|
self.endpointConf=endpointConf
|
|
342
343
|
self.sparql=SPARQL(endpointConf.endpoint,method=self.endpointConf.method)
|
|
343
344
|
self.sparql.debug=self.debug
|
|
345
|
+
self.subclassPredicate=subclassPredicate
|
|
344
346
|
self.where=f"\n {where}" if where is not None else ""
|
|
345
347
|
self.lang=lang
|
|
346
348
|
self.item=WikidataItem(itemQid,sparql=self.sparql,lang=lang)
|
|
@@ -369,7 +371,7 @@ SELECT (COUNT (DISTINCT ?item) AS ?count)
|
|
|
369
371
|
WHERE
|
|
370
372
|
{{
|
|
371
373
|
# instance of {self.item.qlabel}
|
|
372
|
-
?item
|
|
374
|
+
?item {self.subclassPredicate} wd:{self.item.qid}.{self.where}
|
|
373
375
|
}}"""
|
|
374
376
|
try:
|
|
375
377
|
count=self.sparql.getValue(query, "count")
|
|
@@ -471,7 +473,7 @@ SELECT ?{item.itemVarname} ?{item.labelVarname}"""
|
|
|
471
473
|
sparqlQuery+=f"""
|
|
472
474
|
WHERE {{
|
|
473
475
|
# instanceof {item.qid}:{item.qlabel}
|
|
474
|
-
?{item.itemVarname}
|
|
476
|
+
?{item.itemVarname} {self.subclassPredicate} wd:{item.qid}.
|
|
475
477
|
# label
|
|
476
478
|
?{item.itemVarname} rdfs:label ?{item.labelVarname}.
|
|
477
479
|
FILTER (LANG(?{item.labelVarname}) = "{lang}").
|
|
@@ -525,7 +527,7 @@ WHERE {{
|
|
|
525
527
|
whereClause(str): an extra WhereClause to use
|
|
526
528
|
'''
|
|
527
529
|
if whereClause is None:
|
|
528
|
-
whereClause=f"?item
|
|
530
|
+
whereClause=f"?item {self.subclassPredicate} wd:{self.itemQid}";
|
|
529
531
|
if self.endpointConf.database!="qlever":
|
|
530
532
|
whereClause+=";?p ?id"
|
|
531
533
|
whereClause+="."
|
|
@@ -589,7 +591,7 @@ ORDER BY DESC (?count)
|
|
|
589
591
|
WHERE
|
|
590
592
|
{{
|
|
591
593
|
# instance of {self.item.qlabel}
|
|
592
|
-
?item
|
|
594
|
+
?item {self.subclassPredicate} wd:{self.itemQid}.{self.where}
|
|
593
595
|
?item rdfs:label ?itemLabel.
|
|
594
596
|
FILTER (LANG(?itemLabel) = "{self.lang}").
|
|
595
597
|
# {propertyLabel}
|
|
@@ -641,7 +643,7 @@ ORDER BY DESC(?count)"""
|
|
|
641
643
|
total: total value
|
|
642
644
|
'''
|
|
643
645
|
m[col]=value
|
|
644
|
-
if total > 0:
|
|
646
|
+
if total is not None and total > 0:
|
|
645
647
|
m[f"{col}%"]=float(f"{value/total*100:.1f}")
|
|
646
648
|
else:
|
|
647
649
|
m[f"{col}%"] = None
|
|
@@ -9,7 +9,7 @@ class Version(object):
|
|
|
9
9
|
Version handling for pyLoDStorage
|
|
10
10
|
'''
|
|
11
11
|
name="pylodstorage"
|
|
12
|
-
version='0.4.
|
|
12
|
+
version='0.4.6'
|
|
13
13
|
date = '2020-09-10'
|
|
14
|
-
updated = '2022-08-
|
|
14
|
+
updated = '2022-08-07'
|
|
15
15
|
description='python List of Dict (Table) Storage library'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|