mardi 26 juillet 2016

SPARQL query REGEX boundary in java returns empty

i'm new SPARQL and Jena. Here i'm using Jena version 2.13. I would like to perform a SPARQL query from java web application with REGEX boundary (\b). I'm using REGEX boundary to match and find exact word.

I'm running the same SPARQL query on protege too.

Here my SPARQL query in java :

                "PREFIX foaf: <http://ift.tt/GzvtQ2; "
                + "PREFIX rdf: <http://ift.tt/1cmhbSZ; "
                + "PREFIX owl: <http://ift.tt/1bhNI86; "
                + "PREFIX xsd: <http://ift.tt/Gzs4An; "
                + "PREFIX rdfs: <http://ift.tt/1cmhdKn; "
                + "PREFIX : <" + CROSS_NS + "> "
                + "SELECT ((?FoodAndBeveragesRecipes) AS ?Resep)((?FoodAndBeverages) AS ?a) "
                + "WHERE{ ?FoodAndBeveragesRecipes :IngR ?_IngR."
                + " ?_IngR :HasIngredients ?FoodAndBeverages;"
                + ":UnitValue ?Value;"
                + " :MeasurementUnit ?Measurements;"
                + " :Ing_Type ?IngType." 
                + "FILTER regex(str(?FoodAndBeverages), \\b\"" + recipe + "\"\\b)}"
                + " ORDER BY ?FoodAndBeveragesRecipes";

recipe is String variabel to store user input, it's received as a parameter.

When i perform the query, Jena returns an empty set (not even null pointer exception) while Protégé return/find the correct results. I don't know if the problem is with the REGEX code or what.

I was wondering why my REGEX is not working correctly ? could anyone help me?

Thanks.




Aucun commentaire:

Enregistrer un commentaire