Skip to content

Commit de36304

Browse files
author
Your Name
committed
Modify querries to avoid timouts
1 parent 341c1f6 commit de36304

File tree

4 files changed

+147
-4
lines changed

4 files changed

+147
-4
lines changed

backend.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,15 @@ def get_lexeme_values(self) -> Tuple[int, int, Optional[int]]:
226226
print("Running queries…")
227227

228228
queries = [
229+
"queries/da.sparql",
230+
"queries/de-not-nouns.sparql",
231+
"queries/de-nouns.sparql",
229232
"queries/default.sparql",
230233
"queries/en.sparql",
231234
"queries/fr.sparql",
232-
"queries/de.sparql",
233-
"queries/sv.sparql",
234235
"queries/he.sparql",
235-
"queries/da.sparql",
236+
"queries/nb.sparql",
237+
"queries/sv.sparql",
236238
"queries/withoutdescriptions.sparql",
237239
]
238240
for filename in queries:

queries/da.sparql

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ WHERE {
113113
FILTER NOT EXISTS { ?item wdt:P31/wdt:P279* wd:Q23010327 }. # fictional objects
114114
FILTER NOT EXISTS { ?item wdt:P136 [].} # genre (music, etc)
115115
FILTER NOT EXISTS { ?item wdt:P31/wdt:P279* wd:Q4167410 }. # disambiguation pages
116-
FILTER NOT EXISTS { ?item wdt:P31/wdt:P279* wd:Q17537576 }. # creative work (very expensive)
116+
#FILTER NOT EXISTS { ?item wdt:P31/wdt:P279* wd:Q17537576 }. # creative work (very expensive)
117117
FILTER NOT EXISTS { ?item wdt:P31/wdt:P279* wd:Q35872 }. # boat (medium expensive)
118118
FILTER NOT EXISTS { ?item a wikibase:Property}. # filter properties
119119
# 2021-08-17

queries/de-not-nouns.sparql

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
SELECT ?lexeme ?item ?lemma ?desc ?cat ?genus (wd:Q188 as ?lang) WITH {
2+
SELECT *
3+
WHERE {
4+
?lexeme wikibase:lemma ?lemma;
5+
dct:language wd:Q188;
6+
wikibase:lexicalCategory ?cat.
7+
OPTIONAL { ?lexeme wdt:P5185 ?genus. } .
8+
FILTER NOT EXISTS {
9+
?lexeme ontolex:sense ?sense.
10+
?sense wdt:P5137 ?item.
11+
}.
12+
FILTER NOT EXISTS { ?item a wikibase:Property}.
13+
FILTER NOT EXISTS { ?lexeme wikibase:lexicalCategory wd:Q1084 }.
14+
FILTER NOT EXISTS { ?lexeme wdt:P5402 ?homograph }.
15+
?item rdfs:label ?lemma.
16+
?item schema:description ?desc.
17+
FILTER(LANG(?desc) = "de").
18+
}} AS %i
19+
WHERE {
20+
include %i
21+
# Filter out common false-positives
22+
FILTER NOT EXISTS { ?item wdt:P131 ?_ }.
23+
FILTER NOT EXISTS {
24+
VALUES ?not {
25+
wd:Q101352 # family name
26+
wd:Q11424 # Movie
27+
wd:Q11446 # ships
28+
wd:Q11668273 # shogi pieces
29+
wd:Q1229071 # motif
30+
wd:Q13417114 # noble family
31+
wd:Q1391494 # technical terminology
32+
wd:Q147276 # names of any kind
33+
wd:Q15632617 # fictive person
34+
wd:Q15642541 # human settlement definions
35+
wd:Q17155032 # type of software
36+
wd:Q1725664 # terminology of any kind
37+
wd:Q17537576 # any creative work incl. music, video, text, etc.
38+
wd:Q17638537 # routine - fix computer terminology
39+
wd:Q19798644 # wikibase model terms
40+
wd:Q19798645 # wikibase datatype
41+
wd:Q20202269 # music terms
42+
wd:Q208569 # album
43+
wd:Q21191270 # tv series episode
44+
wd:Q215380 # bands
45+
wd:Q2235308 # types of ships
46+
wd:Q23786 # eye color
47+
wd:Q3305213 # painting
48+
wd:Q3491429 # military terms
49+
wd:Q395 # math
50+
wd:Q40056 # software
51+
wd:Q4167410 # disambiguation page
52+
wd:Q4167836 # wikimedia cat
53+
wd:Q43229 # organization of any kind
54+
wd:Q482994 # album
55+
wd:Q494452 # heraldry
56+
wd:Q5 # human
57+
wd:Q5185279 # poem
58+
wd:Q56876983 # symbol (heraldic)
59+
wd:Q57814795 # domesticated animal
60+
wd:Q7187 # gene
61+
wd:Q7366 # song
62+
wd:Q7397 # software
63+
wd:Q8134 # economics
64+
wd:Q191067 # article
65+
}.
66+
?item wdt:P31 ?not }.
67+
}

queries/de-nouns.sparql

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
SELECT ?lexeme ?item ?lemma ?desc (wd:Q1084 as ?cat) ?genus (wd:Q188 as ?lang) WITH {
2+
SELECT *
3+
WHERE {
4+
?lexeme wikibase:lemma ?lemma;
5+
dct:language wd:Q188;
6+
wikibase:lexicalCategory wd:Q1084.
7+
OPTIONAL { ?lexeme wdt:P5185 ?genus. } .
8+
FILTER NOT EXISTS {
9+
?lexeme ontolex:sense ?sense.
10+
?sense wdt:P5137 ?item.
11+
}.
12+
FILTER NOT EXISTS { ?item a wikibase:Property}.
13+
FILTER NOT EXISTS { ?lexeme wdt:P5402 ?homograph }.
14+
?item rdfs:label ?lemma.
15+
?item schema:description ?desc.
16+
FILTER(LANG(?desc) = "de").
17+
}} AS %i
18+
WHERE {
19+
include %i
20+
# Filter out common false-positives
21+
FILTER NOT EXISTS { ?item wdt:P131 ?_ }.
22+
FILTER NOT EXISTS {
23+
VALUES ?not {
24+
wd:Q101352 # family name
25+
wd:Q11424 # Movie
26+
wd:Q11446 # ships
27+
wd:Q11668273 # shogi pieces
28+
wd:Q1229071 # motif
29+
wd:Q13417114 # noble family
30+
wd:Q1391494 # technical terminology
31+
wd:Q147276 # names of any kind
32+
wd:Q15632617 # fictive person
33+
wd:Q15642541 # human settlement definions
34+
wd:Q17155032 # type of software
35+
wd:Q1725664 # terminology of any kind
36+
wd:Q17537576 # any creative work incl. music, video, text, etc.
37+
wd:Q17638537 # routine - fix computer terminology
38+
wd:Q19798644 # wikibase model terms
39+
wd:Q19798645 # wikibase datatype
40+
wd:Q20202269 # music terms
41+
wd:Q208569 # album
42+
wd:Q21191270 # tv series episode
43+
wd:Q215380 # bands
44+
wd:Q2235308 # types of ships
45+
wd:Q23786 # eye color
46+
wd:Q3305213 # painting
47+
wd:Q3491429 # military terms
48+
wd:Q395 # math
49+
wd:Q40056 # software
50+
wd:Q4167410 # disambiguation page
51+
wd:Q4167836 # wikimedia cat
52+
wd:Q43229 # organization of any kind
53+
wd:Q482994 # album
54+
wd:Q494452 # heraldry
55+
wd:Q5 # human
56+
wd:Q5185279 # poem
57+
wd:Q56876983 # symbol (heraldic)
58+
wd:Q57814795 # domesticated animal
59+
wd:Q7187 # gene
60+
wd:Q7366 # song
61+
wd:Q7397 # software
62+
wd:Q8134 # economics
63+
wd:Q191067 # article
64+
}.
65+
?item wdt:P31/(wdt:P279*) ?not }.
66+
# filter on properties:
67+
FILTER NOT EXISTS {
68+
VALUES ?not2 {
69+
wdt:P688 # gene stuff
70+
wdt:P195 # collection (of art)
71+
wdt:P1482 # stack exchange
72+
}
73+
?item ?not2 ?_ }.
74+
}

0 commit comments

Comments
 (0)