Skip to content

Commit

Permalink
queries: harmonize work type detection
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlath committed Nov 9, 2019
1 parent 3d4911b commit 107218f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 32 deletions.
5 changes: 4 additions & 1 deletion server/data/wikidata/queries/editions_reverse_claims.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ module.exports =
?item wdt:#{pid} wd:#{qid} .
?item wdt:P31 wd:Q3331189 .
# Filter-out entities tagged as both work and edition
FILTER NOT EXISTS { ?item wdt:P31 wd:Q571 }
FILTER NOT EXISTS {
?item wdt:P31 ?work_type
VALUES (?work_type) { (wd:Q571) (wd:Q47461344) (wd:Q7725634) (wd:Q2831984) (wd:Q1004) (wd:Q1760610) (wd:Q8274) } .
}
}
LIMIT 1000
"""
12 changes: 2 additions & 10 deletions server/data/wikidata/queries/humans_reverse_claims.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@ module.exports =
# Keep only humans that are known for at least one work
?work wdt:P50 ?item .
# book
{ ?work wdt:P31 wd:Q571 . }
# literary work
UNION { ?work wdt:P31 wd:Q7725634 . }
# comic book album
UNION { ?work wdt:P31 wd:Q2831984 . }
# comic book
UNION { ?work wdt:P31 wd:Q1004 . }
# manga
UNION { ?work wdt:P31 wd:Q8274 . }
?work wdt:P31 ?work_type .
VALUES (?work_type) { (wd:Q571) (wd:Q47461344) (wd:Q7725634) (wd:Q2831984) (wd:Q1004) (wd:Q1760610) (wd:Q8274) } .
}
LIMIT 1000
"""
2 changes: 1 addition & 1 deletion server/data/wikidata/queries/serie_parts.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module.exports =
?part wdt:P31 wd:Q3331189
# but recover parts that are also instances of work
FILTER NOT EXISTS {
VALUES (?work_type) { (wd:Q571) (wd:Q47461344) (wd:Q2831984) (wd:Q1760610) (wd:Q8274) } .
?part wdt:P31 ?work_type .
VALUES (?work_type) { (wd:Q571) (wd:Q47461344) (wd:Q7725634) (wd:Q2831984) (wd:Q1004) (wd:Q1760610) (wd:Q8274) } .
}
}
Expand Down
22 changes: 2 additions & 20 deletions server/data/wikidata/queries/works_reverse_claims.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,8 @@ module.exports =
"""
SELECT DISTINCT ?item WHERE {
?item wdt:#{pid} wd:#{qid} .
# book
{ ?item wdt:P31 wd:Q571 . }
# literary work
UNION { ?item wdt:P31 wd:Q7725634 . }
# comic book album
UNION { ?item wdt:P31 wd:Q2831984 . }
# comic book
UNION { ?item wdt:P31 wd:Q1004 . }
# manga
UNION { ?item wdt:P31 wd:Q8274 . }
# book series
UNION { ?item wdt:P31 wd:Q277759 . }
# comic book series
UNION { ?item wdt:P31 wd:Q14406742 . }
# manga series
UNION { ?item wdt:P31 wd:Q21198342 . }
# novel series
UNION { ?item wdt:P31 wd:Q1667921 . }
# Filter-out entities tagged as both work and edition
FILTER NOT EXISTS { ?item wdt:P31 wd:Q3331189 }
?item wdt:P31 ?work_type .
VALUES (?work_type) { (wd:Q571) (wd:Q47461344) (wd:Q7725634) (wd:Q2831984) (wd:Q1004) (wd:Q1760610) (wd:Q8274) } .
}
LIMIT 1000
"""

0 comments on commit 107218f

Please sign in to comment.