public class LabelService
extends com.bigdata.rdf.sparql.ast.eval.AbstractServiceFactory
SELECT *
WHERE {
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en,de,fr" .
wd:Q123 rdfs:label ?q123Label .
wd:Q123 rdfs:altLabel ?q123Alt .
wd:Q123 schema:description ?q123Desc .
wd:Q321 rdf:label ?q321Label .
}
}
or like this:
SELECT ?sLabel ?sAltLabel ?sDescription ?oLabel
WHERE {
?s wdt:P22 ?o .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en,de" .
bd:serviceParam wikibase:language "fr" .
}
}
If the label isn't available in any of the fallback languages it'll come back as the entityId. Alt labels and descriptions just come back unbound if they don't exist. If multiple values are defined they come back as a comma separated list.
This works by resolving the label-like thing per incoming binding, one at a time. It would probably be faster to do something bulkish but we don't do that yet. The code to do the comma separated lists and entityIds is pretty simple once you've resolve the data.
The second invocation pattern works using EmptyLabelServiceOptimizer
to inspect the query and automatically build the first form out of the second
form by inspecting the query's projection.
| Modifier and Type | Field and Description |
|---|---|
static org.openrdf.model.URI |
SERVICE_KEY
The URI service key.
|
| Constructor and Description |
|---|
LabelService() |
| Modifier and Type | Method and Description |
|---|---|
com.bigdata.rdf.sparql.ast.service.BigdataServiceCall |
create(com.bigdata.rdf.sparql.ast.service.ServiceCallCreateParams params,
com.bigdata.rdf.sparql.ast.eval.ServiceParams serviceParams) |
com.bigdata.rdf.sparql.ast.service.IServiceOptions |
getServiceOptions() |
static void |
register()
Register the service so it is recognized by Blazegraph.
|
public static void register()
public com.bigdata.rdf.sparql.ast.service.IServiceOptions getServiceOptions()
public com.bigdata.rdf.sparql.ast.service.BigdataServiceCall create(com.bigdata.rdf.sparql.ast.service.ServiceCallCreateParams params,
com.bigdata.rdf.sparql.ast.eval.ServiceParams serviceParams)
create in class com.bigdata.rdf.sparql.ast.eval.AbstractServiceFactoryCopyright © 2016. All rights reserved.