1

I am trying to return dbpedia entries for Wiktionary terms by searching for the term using the RDFSharp library. (Once I have the term, I'll get additional properties, but for now I just need to know if I'm approaching this the right way.)

My current implementation (below) only returns empty result sets.

How can I modify my RDFQuery and the dependent object instances to return get the dbpedia entry for a specific Wiktionary term by matching part of speech and the term string?

I used a related example SPARQL query from SO (How to get all nouns in a certain language from Wiktionary using SPARQL) and the RDFSharp query docs as a starting point.

...

//spaql generated by rdfsharp
PREFIX terms: <http://wiktionary.dbpedia.org/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT *
WHERE {
  {
    ?TERM terms:hasPoS terms: Noun .
    FILTER ( ?TERMLABEL = "dog" ) 
  }
}
LIMIT 5
//end sparql fragment


//C# 
RDFSPARQLEndpoint dbPedidaWiktionaryEndpoint = new RDFSPARQLEndpoint(new Uri(@"https://dbpedia.org/sparql"));

RDFNamespace terms = new RDFNamespace("terms", "http://wiktionary.dbpedia.org/terms/");
RDFNamespace dc = new RDFNamespace("dc", "http://purl.org/dc/elements/1.1/");
RDFNamespace rdfs = new RDFNamespace("rdfs", "http://www.w3.org/2000/01/rdf-schema#");

RDFResource termsHasPos = new RDFResource(terms + "hasPoS");
RDFResource termsNoun = new RDFResource(terms + "Noun");
RDFResource termsEnglish = new RDFResource(terms + "English");

// Create variables
RDFVariable searchTerm = new RDFVariable("term"); //passed in 
RDFVariable termLabel = new RDFVariable("termLabel");

RDFPatternGroup PG1 = new RDFPatternGroup();

RDFPattern termIsANoun = new RDFPattern(searchTerm, termsHasPos, termsNoun);


RDFModifier limitReturnCount = new RDFLimitModifier(5);



PG1.AddPattern(termIsANoun)
   .AddFilter(new RDFComparisonFilter( RDFQueryEnums.RDFComparisonFlavors.EqualTo, termLabel, new RDFPlainLiteral(term)));

RDFSPARQLEndpointQueryOptions endpointQueryOptions = new RDFSPARQLEndpointQueryOptions();

endpointQueryOptions.TimeoutMilliseconds = 30000;

RDFGraph graph = new RDFGraph();
// Compose query
RDFSelectQuery query = new RDFSelectQuery()
    .AddPrefix(terms)
    .AddPrefix(dc)
    .AddPrefix(rdfs)
    .AddPatternGroup(PG1)
    .AddModifier(limitReturnCount);

//have tried these "flavors" of query invocations, jic, alway empty result :/
//RDFSelectQueryResult selectResult = await query.ApplyToSPARQLEndpointAsync(dbPedidaWiktionaryEndpoint, endpointQueryOptions);
//RDFSelectQueryResult selectResult = query.ApplyToGraph(graph);
RDFSelectQueryResult selectResult = await query.ApplyToGraphAsync(graph);

string queryText = query.ToString();

starball
  • 20,030
  • 7
  • 43
  • 238
David Gerding
  • 232
  • 3
  • 10
  • 1
    you are querying the wrong endpoint or not? I mean, your query is asking for Wiktionary specific data, but you're asking the DBpedia endpoint – UninformedUser Jan 02 '23 at 06:38
  • Isn't the Wiktionary DBPedia endpoint dead for a few years anyway? – IS4 Jan 03 '23 at 15:12
  • yep, it was basically a student project in my former group, but nobody ever had the resources to continue or maintain it afaik. Not sure if there is any up to data dump, though somebody might try to build one based on https://github.com/dbpedia/dbpedia-wiktionary – UninformedUser Jan 04 '23 at 09:31
  • Thanks for the feedback. I am going to use Wikidata for what I need for now. – David Gerding Jan 13 '23 at 21:25
  • 1
    DBnary is also a maintained project with Wiktionary extracted into the semantic web: http://kaiko.getalp.org/about-dbnary/ – Pux Feb 26 '23 at 17:20

0 Answers0