SPARQL - Filter all instances that only contain a condition - filter

I have recipes with ingredients that have a category.
#prefix schema: <http://schema.org/> .
#prefix ex: <http://example.org> .
ex:recipe1 a schema:Recipe ;
schema:recipeIngredient ex:ingredient1 , ex:ingredient3 .
ex:recipe2 a schema:Recipe ;
schema:recipeIngredient ex:ingredient1, ex:ingredient2 .
ex:ingredient1 ex:category ex:plant .
ex:ingredient2 ex:category ex:spice .
ex:ingredient3 ex:category ex:meat .
ex:ingredient4 ex:category ex:fish .
I want to filter all recipes that only contain ingredients from the category ex:plants or ex:spice. I tried:
SELECT ?recipes
WHERE {
?recipes a schema:Recipe;
schema:recipeIngredient ?ingredient.
?ingredient ex:category ?category.
FILTER(?category NOT IN (ex:meat && ex:fish))
}
This returns both recipes, I guess because ex:recipe1 also includes a ex:plant. However, my desired output is only ex:recipe2 because it does not contain any ex:meat or ex:fish. If any ex:meat or ex:fish is included in the recipes, I want it to be excluded from the result set.

Related

Stardog raises ConcurrentModificationException upon reasoned query on graph with SWRL Rules

When trying to execute a query with reasoning in a model, I get this error: 000012: com.complexible.stardog.plan.eval.operator.OperatorException: Uncaught error during query evaluation: ConcurrentModificationException
Ontology model has 2 SWRL rules and is consistent, as it runs fine in Protege (with built-in pellet reasoner). Model has been imported into a stardog rdf model and the query
SELECT ?tse
FROM <urn:test_graph>
{
?tse a :TaperedShaftEnd
}
fails with the above error message.
By deleting the SWRL rules the query runs fine, but of course the model does no longer represent the desired domain. By translating the SWRL rules into stardog native rules, the error appears again.
Reasoning level is set to DL, as SL would imply too high processing times for the target application.
Changing the sameAs flag in the reasoner options does not change the behavior.
Setting the reasoning level to SL, as advised generally in Stardog documentation would solve the problem on this simplified model, but as said would result impractical for the use on the final target application.
May you help me in identifying the root cause and the possible solution?
Did anyone experienced the same issue when dealing with SWRL rules?
Here below the concerned model in turtle format, to easily replicate the issue on a test graph.
Heartful thanks to anyone who may help me with this.
#prefix : <http://api.stardog.com/> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix stardog: <tag:stardog:api:> .
#prefix test: <urn:test_graph#> .
<http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled> a owl:AnnotationProperty .
<urn:test> a owl:Ontology .
:hasTorqueTransmissionConnectionWith a owl:ObjectProperty , owl:FunctionalProperty , owl:InverseFunctionalProperty , owl:SymmetricProperty , owl:IrreflexiveProperty .
:CouplingConnection a owl:Class ;
owl:disjointWith :ShaftEnd .
:ShaftEnd a owl:Class ;
owl:disjointWith :ShaftEnd .
:LeftCouplingConnection a owl:Class ;
rdfs:subClassOf :CouplingConnection ;
owl:disjointWith :RightCouplingConnection .
:RightCouplingConnection a owl:Class ;
rdfs:subClassOf :CouplingConnection .
:LeftShaftEnd a owl:Class ;
rdfs:subClassOf :ShaftEnd ;
owl:disjointWith :RightShaftEnd .
:RightShaftEnd a owl:Class ;
rdfs:subClassOf :ShaftEnd .
:TaperedCouplingConnection a owl:Class , <tag:stardog:api:rule:SPARQLRule> ;
rdfs:subClassOf :CouplingConnection ;
<tag:stardog:api:rule:content> """IF {
?tse a :TaperedShaftEnd .
?tse :hasTorqueTransmissionConnectionWith ?cc .
?cc a :CouplingConnection .
}
THEN {
?cc a :TaperedCouplingConnection .
}
""" .
:TaperedShaftEnd a owl:Class , <tag:stardog:api:rule:SPARQLRule> ;
rdfs:subClassOf :ShaftEnd ;
<tag:stardog:api:rule:content> """IF {
?tcc a :TaperedCouplingConnection .
?tcc :hasTorqueTransmissionConnectionWith ?se .
?se a :ShaftEnd .
}
THEN {
?se a :TaperedShaftEnd .
}
""" .
:lcc1 a :LeftCouplingConnection , owl:NamedIndividual .
:lse2 a :LeftShaftEnd , owl:NamedIndividual .
:rcc2 a :RightCouplingConnection , :TaperedCouplingConnection , owl:NamedIndividual ;
:hasTorqueTransmissionConnectionWith :lse2 .
:rse1 a :RightShaftEnd , owl:NamedIndividual ;
:hasTorqueTransmissionConnectionWith :lcc1 .

Convert Query from Codeigniter to Laravel 8

How to write this query in laravel? this query was used in Codeigniter
$ci->db->query("SELECT ratings.rating_id," . $table . "." . $namefield . " as thenamefield,ROUND(AVG(ratings.rating_num),2) as rating
FROM ratings," . $table . " WHERE " . $table . "." . $idfield . " = ratings.rating_id GROUP BY rating_id
ORDER BY rating DESC LIMIT " . $limit . "");
try this
$select_part = $table . "." . $namefield;
DB::table('ratings')
->select('ratings.rating_id',DB::raw("{$select_part} as thenamefield"),DB::raw("ROUND(AVG(ratings.rating_num)2) as rating"))
->crossJoin($table)
->whereRaw("{$select_part} = ratings.rating_id")
->groupBy("rating_id")
->orderByRaw("rating DESC")
->limit($limit)
->get();

Excel file with Multiple Sheets in Laravel-Excel 3.1 -> Import Original and Store + Store Individual sheets after cell validations

Thanks for the reaching out to my question, but i have got a problem, I'm trying to Import an excel file with multiple sheets.
Find sheets by some cell-value validation, like if on cell E7, i have a value, store this sheet as separate file. I'm doing mapping() for cell values, and then trying to use Excel::store to save each individual sheet separately. Can't receive any data for individual sheets
Also store the original file. This works!
The issue is, i can't receive any data for storing individual-sheets as excel files, i can create the individual excel files, but no data is being received, or maybe i'm not using the right data-format mentioned on documentation.
Please also check the code. Any help would be appreciated.
public function mapping(): array
{
return [
'altafit_id' => 'E7',
'year' => 'B3',
'initial_month' => 'B4',
'final_month' => 'B5',
];
}
public function model(array $row)
{
// dd($row);
$name = $row['altafit_id'];
$year = $row['year'];
$initial_month = $row['initial_month'];
$final_month = $row['final_month'];
$file_type = 'club';
// dd(collect((object) $row));
Excel::store(collect((object) $row), 'P&L_' . $name . '_' . $year . '_' . $initial_month . '_06' . ',clubs' . ',' . $initial_month . ',' . $final_month . '.' . 'xls', 'public');
return new Files([
//'user_id' => $row['user_id'],
'file_name' => 'P&L_' . $name . '_' . $year . '_' . $initial_month . '_06' . ',clubs' . ',' . $initial_month . ',' . $final_month . '.' . 'xls',
'file_type' => $file_type
]);
}
Already check the documentation, but doesn't work for me.
https://docs.laravel-excel.com/3.1/getting-started/

Get latitude and longitude given name and address

I have a CSV file with name,area,city fieds and I'm expecting that CSV with following fields name,area,city,latitude,longitude
Can any one suggest which API is best for these,
I already tried
Google API's
Textsearch: this is giving overall city wise. Not particular
eg: kfc, in jp nagar 1st phase, bangalore it throws all over bangalore kfc list
I want exactly
echo $url = "https://maps.googleapis.com/maps/api/geocode/json?address=" . $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key;
Which API will fulfill my requirement?
I tried this also
$url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=". $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key;

Catalog search is not working properly

Hi all I am Searching one product in search box but magneto will display Searching product as well as some other product. How to over come this issue??
You can change search options in the backend:
System -> Configuration -> Catalog -> Catalog Search
You can choose search type as 'Like', 'Fulltext' and 'Combine', which are explained in more detail here.
GO to the admin section System -> Configuration -> Catalog -> Catalog Search.
Select fulltext and save.
Then open file app/code/core/Mage/CatalogSearch/Model/resources/Fulltext.php
and make changes in the code as follows:
$likeCond = '(' . join(' OR ', $like) . ')';
to
$likeCond = '(' . join(' AND', $like) . ')';
&
$where .= ($where ? ' OR ' : '') . $likeCond;
to
$where .= ($where ? ' AND ' : '') . $likeCond;

Resources