From: anji r. <anj...@gm...> - 2012-03-31 16:18:07
|
Dear sir/madam, I have a OWL/RDF financial domain file locally which is developed by using protege tool, Now i am using dotNetRDF library to query my local OWL/RDF file through microsoft visual studio C# programatically to get the synonym or related terms/words according to the user input. I followed some code from a blog, but it is giving the ERROR that file doesn't exist. The ERROR Line is: g.LoadFromFile(" FinancialInvestment.rdf"); I tried in different ways of giving path including of copyied file to the project bin folder etc... but unsucceded. could u please help regarding this.... The following code was used by me...... //Define your Graph here IGraph g = new Graph(); //Load some data into your Graph using the LoadFromFile() extension method g.LoadFromFile("myfile.rdf"); //Use the extension method ExecuteQuery() to make the query against the Graph try { Object results = g.ExecuteQuery("SELECT * WHERE { ?s a ?type }"); if (results is SparqlResultSet) { //SELECT/ASK queries give a SparqlResultSet SparqlResultSet rset = (SparqlResultSet)results; foreach (SparqlResult r in rset) { //Do whatever you want with each Result } } else if (results is IGraph) { //CONSTRUCT/DESCRIBE queries give a IGraph IGraph resGraph = (IGraph)results; foreach (Triple t in resGraph.Triples) { //Do whatever you want with each Triple } } else { //If you don't get a SparqlResutlSet or IGraph something went wrong //but didn't throw an exception so you should handle it here Console.WriteLine("ERROR"); } } catch (RdfQueryException queryEx) { //There was an error executing the query so handle it here Console.WriteLine(queryEx.Message); } |