This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-23
Channels
- # announcements (3)
- # architecture (10)
- # babashka (37)
- # beginners (69)
- # calva (2)
- # cider (10)
- # clerk (22)
- # clj-kondo (33)
- # cljdoc (44)
- # clojure (45)
- # clojure-conj (4)
- # clojure-denmark (7)
- # clojure-europe (14)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-uk (4)
- # clojurescript (10)
- # clr (19)
- # conjure (1)
- # emacs (28)
- # events (1)
- # fulcro (1)
- # jobs (1)
- # joyride (1)
- # lsp (18)
- # malli (30)
- # membrane (3)
- # off-topic (23)
- # pathom (45)
- # portal (29)
- # proletarian (7)
- # rdf (15)
- # re-frame (21)
- # reagent (2)
- # releases (6)
- # remote-jobs (1)
- # reveal (6)
- # shadow-cljs (36)
- # slack-help (7)
- # sql (5)
- # tools-deps (3)
Hey SPARQL people, I need to find all resources of a specific type that share the same set of predicate-objects, i.e. they are identical. I have no real idea how to construct a query to return that…
Currently just matching on some attributes and trying to reduce the result set in Clojure. but would be nice to have a single, generalised query for finding duplicates.
i.e. if you’re trying to remove dupes (as opposed to specifically querying for dupes) of a certain type, would the following query be helpful?
SELECT DISTINCT ?s
WHERE {
?s a my:Type
}
If on the other hand you’re trying to specifically find duplicates I think you need to use the COUNT
aggregate and use filters to return when the count > 1
Ah I think HAVING
would be your friend here (not sure if this query actually works but could be worth a shot):
SELECT ?s
WHERE {
?s a my:Type
?s ?p ?o
}
GROUP BY ?p ?o
HAVING (COUNT(?s) > 1)
Thanks, @U02FU7RMG8M!
I don’t have data to play with here, but I’m thinking you could do something like this (in thread)…
select ?s
where{
?s a mytype .
?s ?p ?o .
?s2 a mytype .
?s2 ?p ?o .
FILTER (?s != ?s2)
MINUS{
?s ?px ?ox .
NOT EXISTS { ?s2 ?px ?ox }
}
}
This matches ?s
and ?s2
where they are both mytype
and they share any properties at all.
Then remove any instance of ?s
where there is a property/value and the matching ?s2
does not have that property/value
if ?s
has fewer properties than ?s2
then it will be taken away via the MINUS, but then when the bindings are the other way around ?s
will have more properties than ?s2
and so it won’t be removed via the minus. Which I think works here
The problem is that the above works via a nested loop in the query engine. It doesn’t scale
Thanks @U051N6TTC!