pyLodStorage 0.3.10__tar.gz → 0.3.13__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.3.10/pylodstorage.egg-info → pylodstorage-0.3.13}/PKG-INFO +1 -1
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/trulytabular.py +53 -19
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/version.py +2 -2
- {pylodstorage-0.3.10 → pylodstorage-0.3.13/pylodstorage.egg-info}/PKG-INFO +1 -1
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/LICENSE +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/README.md +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/__init__.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/csv.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/entity.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/jsonable.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/jsonpicklemixin.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/lod.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/mwTable.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/plot.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/query.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/querymain.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/sample.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/schema.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/sparql.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/sql.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/storageconfig.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/tabulateCounter.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/uml.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/xml.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/lodstorage/yamlablemixin.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/pylodstorage.egg-info/SOURCES.txt +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/pylodstorage.egg-info/dependency_links.txt +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/pylodstorage.egg-info/entry_points.txt +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/pylodstorage.egg-info/requires.txt +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/pylodstorage.egg-info/top_level.txt +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/sampledata/__init__.py +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/sampledata/endpoints.yaml +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/sampledata/formats.yaml +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/sampledata/got.yaml +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/sampledata/queries.yaml +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/sampledata/scholia.yaml +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/sampledata/trulytabular.yaml +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/sampledata/wf.yaml +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/sampledata/wikidata.yaml +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/setup.cfg +0 -0
- {pylodstorage-0.3.10 → pylodstorage-0.3.13}/setup.py +0 -0
|
@@ -79,7 +79,7 @@ class WikidataProperty():
|
|
|
79
79
|
for propertyLabel in propertyLabels:
|
|
80
80
|
valuesClause+=f' "{propertyLabel}"@{lang}\n'
|
|
81
81
|
query=f"""# get the properties for the given labels
|
|
82
|
-
{WikidataItem.getPrefixes()}
|
|
82
|
+
{WikidataItem.getPrefixes(["rdf","rdfs","wikibase"])}
|
|
83
83
|
SELECT ?property ?propertyLabel WHERE {{
|
|
84
84
|
VALUES ?propertyLabel {{
|
|
85
85
|
{valuesClause}
|
|
@@ -108,7 +108,7 @@ SELECT ?property ?propertyLabel WHERE {{
|
|
|
108
108
|
valuesClause+=f' wd:{propertyId}\n'
|
|
109
109
|
query=f"""
|
|
110
110
|
# get the property for the given property Ids
|
|
111
|
-
{WikidataItem.getPrefixes()}
|
|
111
|
+
{WikidataItem.getPrefixes(["rdf","rdfs","wd","wikibase"])}
|
|
112
112
|
SELECT ?property ?propertyLabel WHERE {{
|
|
113
113
|
VALUES ?property {{
|
|
114
114
|
{valuesClause}
|
|
@@ -191,16 +191,46 @@ class WikidataItem:
|
|
|
191
191
|
return text
|
|
192
192
|
|
|
193
193
|
@classmethod
|
|
194
|
-
def getPrefixes(cls):
|
|
194
|
+
def getPrefixes(cls,prefixes=["rdf","rdfs","schema","wd","wdt","wikibase","xsd"]):
|
|
195
|
+
prefixMap={
|
|
196
|
+
"bd":"<http://www.bigdata.com/rdf#>",
|
|
197
|
+
"cc":"<http://creativecommons.org/ns#>",
|
|
198
|
+
"dct":"<http://purl.org/dc/terms/>",
|
|
199
|
+
"geo":"<http://www.opengis.net/ont/geosparql#>",
|
|
200
|
+
"ontolex":"<http://www.w3.org/ns/lemon/ontolex#>",
|
|
201
|
+
"owl":"<http://www.w3.org/2002/07/owl#>",
|
|
202
|
+
"p":"<http://www.wikidata.org/prop/>",
|
|
203
|
+
"pq":"<http://www.wikidata.org/prop/qualifier/>",
|
|
204
|
+
"pqn":"<http://www.wikidata.org/prop/qualifier/value-normalized/>",
|
|
205
|
+
"pqv":"<http://www.wikidata.org/prop/qualifier/value/>",
|
|
206
|
+
"pr":"<http://www.wikidata.org/prop/reference/>",
|
|
207
|
+
"prn":"<http://www.wikidata.org/prop/reference/value-normalized/>",
|
|
208
|
+
"prov":"<http://www.w3.org/ns/prov#>",
|
|
209
|
+
"prv":"<http://www.wikidata.org/prop/reference/value/>",
|
|
210
|
+
"ps":"<http://www.wikidata.org/prop/statement/>",
|
|
211
|
+
"psn":"<http://www.wikidata.org/prop/statement/value-normalized/>",
|
|
212
|
+
"psv":"<http://www.wikidata.org/prop/statement/value/>",
|
|
213
|
+
"rdf":"<http://www.w3.org/1999/02/22-rdf-syntax-ns#>",
|
|
214
|
+
"rdfs":"<http://www.w3.org/2000/01/rdf-schema#>",
|
|
215
|
+
"schema":"<http://schema.org/>",
|
|
216
|
+
"skos":"<http://www.w3.org/2004/02/skos/core#>",
|
|
217
|
+
"wd":"<http://www.wikidata.org/entity/>",
|
|
218
|
+
"wdata":"<http://www.wikidata.org/wiki/Special:EntityData/>",
|
|
219
|
+
"wdno":"<http://www.wikidata.org/prop/novalue/>",
|
|
220
|
+
"wdref":"<http://www.wikidata.org/reference/>",
|
|
221
|
+
"wds":"<http://www.wikidata.org/entity/statement/>",
|
|
222
|
+
"wdt":"<http://www.wikidata.org/prop/direct/>",
|
|
223
|
+
"wdtn":"<http://www.wikidata.org/prop/direct-normalized/>",
|
|
224
|
+
"wdv":"<http://www.wikidata.org/value/>",
|
|
225
|
+
"wikibase":"<http://wikiba.se/ontology#>",
|
|
226
|
+
"xsd":"<http://www.w3.org/2001/XMLSchema#>"
|
|
227
|
+
}
|
|
195
228
|
# see also https://www.wikidata.org/wiki/EntitySchema:E49
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
PREFIX
|
|
200
|
-
|
|
201
|
-
PREFIX wikibase: <http://wikiba.se/ontology#>
|
|
202
|
-
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>"""
|
|
203
|
-
return prefixes
|
|
229
|
+
sparql=""
|
|
230
|
+
for prefix in prefixes:
|
|
231
|
+
if prefix in prefixMap:
|
|
232
|
+
sparql+=f"PREFIX {prefix}: {prefixMap[prefix]}\n"
|
|
233
|
+
return sparql
|
|
204
234
|
|
|
205
235
|
@classmethod
|
|
206
236
|
def getLabelAndDescription(cls,sparql:SPARQL, itemId:str,lang:str="en"):
|
|
@@ -215,7 +245,7 @@ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>"""
|
|
|
215
245
|
(str,str): the label and description as a tuple
|
|
216
246
|
'''
|
|
217
247
|
query=f"""# get the label for the given item
|
|
218
|
-
{cls.getPrefixes()}
|
|
248
|
+
{cls.getPrefixes(["rdfs","wd","schema"])}
|
|
219
249
|
SELECT ?itemLabel ?itemDescription
|
|
220
250
|
WHERE
|
|
221
251
|
{{
|
|
@@ -246,7 +276,7 @@ WHERE
|
|
|
246
276
|
query=f"""# get the items that have the given label in the given language
|
|
247
277
|
# e.g. we'll find human=Q5 as the oldest type for the label "human" first
|
|
248
278
|
# and then the newer ones such as "race in Warcraft"
|
|
249
|
-
{cls.getPrefixes()}
|
|
279
|
+
{cls.getPrefixes(["rdfs","schema","xsd"])}
|
|
250
280
|
SELECT
|
|
251
281
|
#?itemId
|
|
252
282
|
?item
|
|
@@ -339,7 +369,7 @@ WHERE
|
|
|
339
369
|
self.error=ex
|
|
340
370
|
count=None
|
|
341
371
|
|
|
342
|
-
return count
|
|
372
|
+
return count,query
|
|
343
373
|
|
|
344
374
|
def asText(self,long:bool=True):
|
|
345
375
|
'''
|
|
@@ -473,7 +503,7 @@ WHERE {{
|
|
|
473
503
|
sparqlQuery+=f"\n)"
|
|
474
504
|
return sparqlQuery
|
|
475
505
|
|
|
476
|
-
def mostFrequentPropertiesQuery(self,whereClause:str=None):
|
|
506
|
+
def mostFrequentPropertiesQuery(self,whereClause:str=None,minCount:int=0):
|
|
477
507
|
'''
|
|
478
508
|
get the most frequently used properties
|
|
479
509
|
|
|
@@ -485,6 +515,9 @@ WHERE {{
|
|
|
485
515
|
if self.endpointConf.database!="qlever":
|
|
486
516
|
whereClause+=";?p ?id"
|
|
487
517
|
whereClause+="."
|
|
518
|
+
minCountFilter=""
|
|
519
|
+
if minCount>0:
|
|
520
|
+
minCountFilter=f"\n FILTER(?count >{minCount})."
|
|
488
521
|
itemText=self.getItemText()
|
|
489
522
|
sparqlQuery=f"""# get the most frequently used properties for
|
|
490
523
|
# {itemText}
|
|
@@ -516,7 +549,7 @@ SELECT ?prop ?propLabel ?count WHERE {{
|
|
|
516
549
|
}}"""
|
|
517
550
|
sparqlQuery+=f"""
|
|
518
551
|
?prop rdfs:label ?propLabel.
|
|
519
|
-
FILTER(LANG(?propLabel) = "{self.lang}")
|
|
552
|
+
FILTER(LANG(?propLabel) = "{self.lang}").{minCountFilter}
|
|
520
553
|
}}
|
|
521
554
|
ORDER BY DESC (?count)
|
|
522
555
|
"""
|
|
@@ -560,7 +593,8 @@ ORDER BY DESC (?frequency)"""
|
|
|
560
593
|
sparql=f"""{sparql}
|
|
561
594
|
HAVING (COUNT (?value) > 1)
|
|
562
595
|
ORDER BY DESC(?count)"""
|
|
563
|
-
|
|
596
|
+
itemText=self.getItemText()
|
|
597
|
+
sparql=f"""# Count all {itemText} items
|
|
564
598
|
# with the given {propertyLabel}({propertyId}) https://www.wikidata.org/wiki/Property:{propertyId}
|
|
565
599
|
{WikidataItem.getPrefixes()}
|
|
566
600
|
"""+sparql
|
|
@@ -632,7 +666,7 @@ ORDER BY DESC(?count)"""
|
|
|
632
666
|
Returns:
|
|
633
667
|
generator: a generator of statistic dict rows
|
|
634
668
|
'''
|
|
635
|
-
itemCount=self.count()
|
|
669
|
+
itemCount,_itemCountQuery=self.count()
|
|
636
670
|
for wdProperty in self.properties.values():
|
|
637
671
|
statsRow=self.genWdPropertyStatistic(wdProperty, itemCount)
|
|
638
672
|
yield statsRow
|
|
@@ -641,7 +675,7 @@ ORDER BY DESC(?count)"""
|
|
|
641
675
|
'''
|
|
642
676
|
get the property Statistics
|
|
643
677
|
'''
|
|
644
|
-
itemCount=self.count()
|
|
678
|
+
itemCount,_itemCountQuery=self.count()
|
|
645
679
|
lod=[{
|
|
646
680
|
"property": "∑",
|
|
647
681
|
"total": itemCount,
|
|
@@ -9,7 +9,7 @@ class Version(object):
|
|
|
9
9
|
Version handling for pyLoDStorage
|
|
10
10
|
'''
|
|
11
11
|
name="pylodstorage"
|
|
12
|
-
version='0.3.
|
|
12
|
+
version='0.3.13'
|
|
13
13
|
date = '2020-09-10'
|
|
14
|
-
updated = '2022-08-
|
|
14
|
+
updated = '2022-08-02'
|
|
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
|