use of org.openrdf.model.impl.LiteralImpl in project wikidata-query-rdf by wikimedia.
the class StatementHelper method basicEntity.
/**
* Construct statements about a basic entity.
*/
public static List<Statement> basicEntity(UrisScheme uris, String id, String versionString, String dateString) {
Literal version = new LiteralImpl(versionString);
List<Statement> statements = new ArrayList<>();
String entityDataUri = uris.entityData() + id;
// EntityData is all munged onto Entity
statement(statements, entityDataUri, SchemaDotOrg.ABOUT, id);
statement(statements, entityDataUri, SchemaDotOrg.VERSION, version);
statement(statements, entityDataUri, SchemaDotOrg.DATE_MODIFIED, new LiteralImpl(dateString));
return statements;
}
use of org.openrdf.model.impl.LiteralImpl in project wikidata-query-rdf by wikimedia.
the class MWApiServiceQueryUnitTest method mwAPI_T168876.
// @Test // disabled test, need to be discussed it it is safe to run in in CI
public void mwAPI_T168876() {
// MWAPI service throws “could not find binding for parameter” if optimizer is not disabled
// https://phabricator.wikimedia.org/T168876
StringBuilder query = uris().prefixes(Ontology.prefix(new StringBuilder()));
add("wd:Q168876", "wdt:P18", new LiteralImpl("http://commons.wikimedia.org/wiki/Special:FilePath/U8%20Berlin%20Leinestrasse%2012-2017.jpg"));
query.append("SELECT * WHERE {\n" + " BIND(wd:Q168876 as ?leinestr) # random item with picture\n" + " ?leinestr wdt:P18 ?picture.\n" + "\n" + " BIND(STRAFTER(str(?picture), \"Special:FilePath/\") AS ?filename)\n" + " BIND(ontology:decodeUri(CONCAT(\"File:\", ?filename)) AS ?file)\n" + "\n" + " SERVICE ontology:mwapi {\n" + " bd:serviceParam ontology:api \"Categories\".\n" + " bd:serviceParam ontology:endpoint \"commons.wikipedia.org\".\n" + " bd:serviceParam mwapi:titles ?file. # throws IllegalArgumentException: Could not find binding for parameter titles\n" + " ?cat ontology:apiOutput mwapi:category.\n" + " }\n" + "}");
assertQueryResult(query.toString(), binds("cat", Literal.class), binds("cat", Literal.class), binds("cat", Literal.class), binds("cat", Literal.class), binds("cat", Literal.class), binds("cat", Literal.class), binds("cat", Literal.class), binds("cat", Literal.class), binds("cat", Literal.class), binds("cat", Literal.class));
}
use of org.openrdf.model.impl.LiteralImpl in project wikidata-query-rdf by wikimedia.
the class LabelServiceUnitTest method addSimpleLabels.
private void addSimpleLabels(String entity) {
for (String language : new String[] { "en", "de", "ru" }) {
add("wd:" + entity, RDFS.LABEL, new LiteralImpl("in " + language, language));
}
add("wd:" + entity, SKOS.ALT_LABEL, new LiteralImpl("alt label in en", "en"));
add("wd:" + entity, SKOS.ALT_LABEL, new LiteralImpl("alt label in en2", "en"));
add("wd:" + entity, SKOS.ALT_LABEL, new LiteralImpl("alt label in de", "de"));
for (String language : new String[] { "en", "de", "ru" }) {
add("wd:" + entity, SchemaDotOrg.DESCRIPTION, new LiteralImpl("description in " + language, language));
}
}
use of org.openrdf.model.impl.LiteralImpl in project wikidata-query-rdf by wikimedia.
the class LabelServiceUnitTest method many.
@Test
public void many() throws QueryEvaluationException {
for (int i = 1; i <= 10; i++) {
addSimpleLabels("Q" + i);
add("ontology:dummy", "ontology:dummy", "wd:Q" + i);
}
TupleQueryResult result = lookupLabel("ontology:dummy ontology:dummy ?o", "en", "?o", "rdfs:label");
for (int i = 1; i <= 10; i++) {
assertTrue(result.hasNext());
assertThat(result.next(), binds("oLabel", new LiteralImpl("in en", "en")));
}
assertFalse(result.hasNext());
}
use of org.openrdf.model.impl.LiteralImpl in project wikidata-query-rdf by wikimedia.
the class WikibaseVocabularyUnitTest method entityPAndQAreBytes.
/**
* Make sure the "P" and "Q" suffixed versions of entity are a byte because
* if they aren't then inline uris are more bloated.
*/
@Test
public void entityPAndQAreBytes() {
BigdataStatement statement = roundTrip(uris().entityIdToURI("P"), uris().entityIdToURI("Q"), new LiteralImpl("cat"));
assertThat(statement.getSubject().getIV(), instanceOf(VocabURIByteIV.class));
assertThat(statement.getPredicate().getIV(), instanceOf(VocabURIByteIV.class));
}
Aggregations