SemanticApplicationDesignLanguage / sadl

Semantic Application Design Language (SADL) Open Source Code
http://semanticapplicationdesignlanguage.github.io/sadl/
Eclipse Public License 1.0
30 stars 12 forks source link

Update query #706

Open NAVEENKUMARSKPN opened 3 years ago

NAVEENKUMARSKPN commented 3 years ago

Hi Team I am trying to use update query but i couldnt find the syntax is there any example that would help me to move forward

  1. we were able to execute the query but its not getting updated

Model is `uri "http://sadl.org/UpdateTests.sadl" alias UpdateTests.

Person is a class described by name with values of type string, described by owns with values of type Thing, described by loves with values of type Thing. Thing is a class. George is a Person with name "George". Fido is a Thing. George owns Fido.

John is a Person with name "Johnny".

Rule LoveWhatYouOwn: if x owns y then x loves y.

Ask Ownership (note "This query is a select."): select s,p where s p Fido. // Update: "delete {?person . ?person } // insert { } // where {?person . ?person 'George'}". Update UpdateToJohn: delete x owns Fido and x loves Fido insert John owns Fido where x owns Fido and x has name "George" . Ask: Ownership.

Update UpdateToJohn.`

when we try executing the UpdateToJohn the query is executed but it didnt updated

  1. will update query is a kind of in-memory and it wont update in sadl or owl file back?
  2. is there any option so that i can update it to sadl or owl file back permanently?
  3. Do i need to give delete and insert . my use case is i want to add new instance for the type without deleting the existing instance

Thanks

crapo commented 3 years ago

@NAVEENKUMARSKPN , when I create a SADL model exactly as you have shared it and run inference I get these results:

Inference of '/home/camfe/andy/ws/sadl/runtime-EclipseApplication2/GH-706/UpdateTests.sadl' requested. Reasoner family: Jena-Based (com.ge.research.sadl.jena.reasoner.JenaReasonerPlugin), version date 12 April 2021. Query: select ?s ?p where {?s ?p http://sadl.org/UpdateTests.sadl#Fido} "s","p" "George","loves" "George","owns" Update: delete {?x http://sadl.org/UpdateTests.sadl#owns http://sadl.org/UpdateTests.sadl#Fido . ?x http://sadl.org/UpdateTests.sadl#loves http://sadl.org/UpdateTests.sadl#Fido} insert {http://sadl.org/UpdateTests.sadl#John http://sadl.org/UpdateTests.sadl#owns http://sadl.org/UpdateTests.sadl#Fido} where {?x http://sadl.org/UpdateTests.sadl#owns http://sadl.org/UpdateTests.sadl#Fido . ?x http://sadl.org/UpdateTests.sadl#name "George"} Query: select ?s ?p where {?s ?p http://sadl.org/UpdateTests.sadl#Fido} "s","p" "John","loves" "John","owns"

That seems to me what I would expect.

WRT your questions:

  1. All inference in the SADL IDE contributes to an in-memory OWL model. It is possible to serialize this model (see Abha's question at https://github.com/SemanticApplicationDesignLanguage/sadl/discussions/713), but the original SADL model is not modified. It is possible in the SadlServer environment to directly persist an inferred model
  2. See https://github.com/SemanticApplicationDesignLanguage/sadl/discussions/713.
  3. Not sure I understand very well. You don't need to delete--you can insert new instances without deleting anything. But to repeat, inference does not change the original model over which inference is performed.
NAVEENKUMARSKPN commented 3 years ago

Thanks Crapo

With Print: Model I were able to get the file in Temp Folder

But while translating it actually generates the owl for builtinsadl's also

  1. I have UpdateTests.sadl and I have update query and then Print: Model exactly the above sadl which i have mentioned. yes it was updated in Temp folder but inside that UpdateTests.sadl.Model.owl.txt file it also had owl translation for SadlBuilInFunctions.sadl and SadlImplicitModels.sadl also.The total number of lines in the generated file is 2076

Is there any way to restrict while translating?

crapo commented 3 years ago

"Print: Model." puts all triples in the current model into the file so that you can see all triples available to the reasoner. It would be an easy enhancement to have an option to print only the base model (this model but not any imports). Using current functionality you might be able to write a SPARQL construct query that would filter results by namespace to get only what you want. I'm envisioning an enhancement like "Print: Base Model."

crapo commented 3 years ago

@NAVEENKUMARSKPN , I was taking a closer look at this and realized that I don't apparently understand the issue. In the IDE, an implementation of "Print: Base Model." would print to a file the same model that is already created in the OwlModels folder when you save a SADL model. So it would have no purpose. What is it exactly that you would like to do?

crapo commented 2 years ago

@NAVEENKUMARSKPN , I'm trying to clean up old issues. Can you please take a look at this and let me know if there is something that you think could/should be done to address what you wish to accomplish?