How to express equals relation in sparql?
up vote
0
down vote
favorite
I am trying to use sparql to find all French labels of words that are related to a given English word.
The query I made is something like the following:
SELECT ?extword ?word ?label where {
?word rdfs:label "shark"@eng.
{?extword rdf:type ?word}
UNION
{?word rdf:type ?extword}.
?extword rdfs:label ?label filter(lang(?label)="fra")
}
While it does give me the French labels of the extword as desired, it does not give the French labels of word itself.
What I need is to insert a clause to express the relation that extword is exactly word, like this:
SELECT ?extword ?word ?label where {
?word rdfs:label "shark"@eng.
{?extword = ?word}
UNION
{?extword rdf:type ?word}
UNION
{?word rdf:type ?extword}.
?extword rdfs:label ?label filter(lang(?label)="fra")
}
It turns out to be syntax error. Is it possible to also include the French labels of word itself, without doing another query?
To be clearer, the result I expect is the result from my first query combined with result from the following query:
SELECT ?word ?label where {
?word rdfs:label "shark"@eng.
?word rdfs:label ?label filter(lang(?label)="fra")
}
sparql rdfs
|
show 8 more comments
up vote
0
down vote
favorite
I am trying to use sparql to find all French labels of words that are related to a given English word.
The query I made is something like the following:
SELECT ?extword ?word ?label where {
?word rdfs:label "shark"@eng.
{?extword rdf:type ?word}
UNION
{?word rdf:type ?extword}.
?extword rdfs:label ?label filter(lang(?label)="fra")
}
While it does give me the French labels of the extword as desired, it does not give the French labels of word itself.
What I need is to insert a clause to express the relation that extword is exactly word, like this:
SELECT ?extword ?word ?label where {
?word rdfs:label "shark"@eng.
{?extword = ?word}
UNION
{?extword rdf:type ?word}
UNION
{?word rdf:type ?extword}.
?extword rdfs:label ?label filter(lang(?label)="fra")
}
It turns out to be syntax error. Is it possible to also include the French labels of word itself, without doing another query?
To be clearer, the result I expect is the result from my first query combined with result from the following query:
SELECT ?word ?label where {
?word rdfs:label "shark"@eng.
?word rdfs:label ?label filter(lang(?label)="fra")
}
sparql rdfs
UNION clauses are executed independently from each other. That's why this can't work. The solution is to use a FILTER besides the UNION pattern, i.e.SELECT ?extword ?word ?label where { ?word rdfs:label "shark"@eng. {?extword rdf:type ?word} UNION {?word rdf:type ?extword}. ?extword rdfs:label ?label filter(lang(?label)="fra") } FILTER(?extword = ?word)}Indeed, this query might be wrong because for me the whole query isn't clear so far.
– AKSW
4 hours ago
What I don't understand is the purpose of the query. Can you show some sample data + the expected result?
– AKSW
4 hours ago
Something like?extword rdf:type|^rdf:type ?wordcould be also used in your query to simplify it
– AKSW
4 hours ago
@AKSW see linkeddata1.calcul.u-psud.fr/…
– NGY
3 hours ago
The expected result are the French labels of all theextwordas well as that of theword. The result of my original query are only the labels ofextword.
– NGY
3 hours ago
|
show 8 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to use sparql to find all French labels of words that are related to a given English word.
The query I made is something like the following:
SELECT ?extword ?word ?label where {
?word rdfs:label "shark"@eng.
{?extword rdf:type ?word}
UNION
{?word rdf:type ?extword}.
?extword rdfs:label ?label filter(lang(?label)="fra")
}
While it does give me the French labels of the extword as desired, it does not give the French labels of word itself.
What I need is to insert a clause to express the relation that extword is exactly word, like this:
SELECT ?extword ?word ?label where {
?word rdfs:label "shark"@eng.
{?extword = ?word}
UNION
{?extword rdf:type ?word}
UNION
{?word rdf:type ?extword}.
?extword rdfs:label ?label filter(lang(?label)="fra")
}
It turns out to be syntax error. Is it possible to also include the French labels of word itself, without doing another query?
To be clearer, the result I expect is the result from my first query combined with result from the following query:
SELECT ?word ?label where {
?word rdfs:label "shark"@eng.
?word rdfs:label ?label filter(lang(?label)="fra")
}
sparql rdfs
I am trying to use sparql to find all French labels of words that are related to a given English word.
The query I made is something like the following:
SELECT ?extword ?word ?label where {
?word rdfs:label "shark"@eng.
{?extword rdf:type ?word}
UNION
{?word rdf:type ?extword}.
?extword rdfs:label ?label filter(lang(?label)="fra")
}
While it does give me the French labels of the extword as desired, it does not give the French labels of word itself.
What I need is to insert a clause to express the relation that extword is exactly word, like this:
SELECT ?extword ?word ?label where {
?word rdfs:label "shark"@eng.
{?extword = ?word}
UNION
{?extword rdf:type ?word}
UNION
{?word rdf:type ?extword}.
?extword rdfs:label ?label filter(lang(?label)="fra")
}
It turns out to be syntax error. Is it possible to also include the French labels of word itself, without doing another query?
To be clearer, the result I expect is the result from my first query combined with result from the following query:
SELECT ?word ?label where {
?word rdfs:label "shark"@eng.
?word rdfs:label ?label filter(lang(?label)="fra")
}
sparql rdfs
sparql rdfs
edited 3 hours ago
asked 4 hours ago
NGY
1436
1436
UNION clauses are executed independently from each other. That's why this can't work. The solution is to use a FILTER besides the UNION pattern, i.e.SELECT ?extword ?word ?label where { ?word rdfs:label "shark"@eng. {?extword rdf:type ?word} UNION {?word rdf:type ?extword}. ?extword rdfs:label ?label filter(lang(?label)="fra") } FILTER(?extword = ?word)}Indeed, this query might be wrong because for me the whole query isn't clear so far.
– AKSW
4 hours ago
What I don't understand is the purpose of the query. Can you show some sample data + the expected result?
– AKSW
4 hours ago
Something like?extword rdf:type|^rdf:type ?wordcould be also used in your query to simplify it
– AKSW
4 hours ago
@AKSW see linkeddata1.calcul.u-psud.fr/…
– NGY
3 hours ago
The expected result are the French labels of all theextwordas well as that of theword. The result of my original query are only the labels ofextword.
– NGY
3 hours ago
|
show 8 more comments
UNION clauses are executed independently from each other. That's why this can't work. The solution is to use a FILTER besides the UNION pattern, i.e.SELECT ?extword ?word ?label where { ?word rdfs:label "shark"@eng. {?extword rdf:type ?word} UNION {?word rdf:type ?extword}. ?extword rdfs:label ?label filter(lang(?label)="fra") } FILTER(?extword = ?word)}Indeed, this query might be wrong because for me the whole query isn't clear so far.
– AKSW
4 hours ago
What I don't understand is the purpose of the query. Can you show some sample data + the expected result?
– AKSW
4 hours ago
Something like?extword rdf:type|^rdf:type ?wordcould be also used in your query to simplify it
– AKSW
4 hours ago
@AKSW see linkeddata1.calcul.u-psud.fr/…
– NGY
3 hours ago
The expected result are the French labels of all theextwordas well as that of theword. The result of my original query are only the labels ofextword.
– NGY
3 hours ago
UNION clauses are executed independently from each other. That's why this can't work. The solution is to use a FILTER besides the UNION pattern, i.e.
SELECT ?extword ?word ?label where { ?word rdfs:label "shark"@eng. {?extword rdf:type ?word} UNION {?word rdf:type ?extword}. ?extword rdfs:label ?label filter(lang(?label)="fra") } FILTER(?extword = ?word)} Indeed, this query might be wrong because for me the whole query isn't clear so far.– AKSW
4 hours ago
UNION clauses are executed independently from each other. That's why this can't work. The solution is to use a FILTER besides the UNION pattern, i.e.
SELECT ?extword ?word ?label where { ?word rdfs:label "shark"@eng. {?extword rdf:type ?word} UNION {?word rdf:type ?extword}. ?extword rdfs:label ?label filter(lang(?label)="fra") } FILTER(?extword = ?word)} Indeed, this query might be wrong because for me the whole query isn't clear so far.– AKSW
4 hours ago
What I don't understand is the purpose of the query. Can you show some sample data + the expected result?
– AKSW
4 hours ago
What I don't understand is the purpose of the query. Can you show some sample data + the expected result?
– AKSW
4 hours ago
Something like
?extword rdf:type|^rdf:type ?word could be also used in your query to simplify it– AKSW
4 hours ago
Something like
?extword rdf:type|^rdf:type ?word could be also used in your query to simplify it– AKSW
4 hours ago
@AKSW see linkeddata1.calcul.u-psud.fr/…
– NGY
3 hours ago
@AKSW see linkeddata1.calcul.u-psud.fr/…
– NGY
3 hours ago
The expected result are the French labels of all the
extword as well as that of the word. The result of my original query are only the labels of extword.– NGY
3 hours ago
The expected result are the French labels of all the
extword as well as that of the word. The result of my original query are only the labels of extword.– NGY
3 hours ago
|
show 8 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369768%2fhow-to-express-equals-relation-in-sparql%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
UNION clauses are executed independently from each other. That's why this can't work. The solution is to use a FILTER besides the UNION pattern, i.e.
SELECT ?extword ?word ?label where { ?word rdfs:label "shark"@eng. {?extword rdf:type ?word} UNION {?word rdf:type ?extword}. ?extword rdfs:label ?label filter(lang(?label)="fra") } FILTER(?extword = ?word)}Indeed, this query might be wrong because for me the whole query isn't clear so far.– AKSW
4 hours ago
What I don't understand is the purpose of the query. Can you show some sample data + the expected result?
– AKSW
4 hours ago
Something like
?extword rdf:type|^rdf:type ?wordcould be also used in your query to simplify it– AKSW
4 hours ago
@AKSW see linkeddata1.calcul.u-psud.fr/…
– NGY
3 hours ago
The expected result are the French labels of all the
extwordas well as that of theword. The result of my original query are only the labels ofextword.– NGY
3 hours ago