GEGlobalResearch / DARPA-ASKE-TA1

ANSWER Project to demonstrate knowledge-driven extraction of scientific models from code and texts
Other
8 stars 5 forks source link

QuickFix from aliases #81

Open crapo opened 4 years ago

crapo commented 4 years ago

@kittaakos , as nearly as I can tell, quick fixes from alias was merged into development on Feb 10 and development into MissingPatterns on Feb 17, so I think I should have this in MissingPatterns. I was hoping that it would be inherited by Dialog. Here's a SADL example that I thought should work but doesn't:

PO is a class.
velocity (alias "speed") describes PO with values of type UnittedQuantity.
PO is a class.
MyPo is a PO with speed 23 mph.

I expected to have a quick fix to change "speed" to "velocity" on the last line.

Here's a Dialog example for a Dialog importing the ontology above. what is speed?

kittaakos commented 4 years ago

I'll take care of this.

kittaakos commented 4 years ago

as nearly as I can tell, quick fixes from alias was merged into development on Feb 10 and development into MissingPatterns on Feb 17, so I think I should have this in MissingPatterns.

Yes, you have. It is there.

I was hoping that it would be inherited by Dialog.

It is inherited as far as I can tell. The dialog quick fix provider extends the SADL one.

Here's a SADL example that I thought should work but doesn't:

The Jena based SADL model processor should take care of adding a warning. Like we do in this example:

uri "http://sadl.org/x.sadl".
Engine is a class described  by sfc (alias "fuel burn") with values of type float.
MyEngine is an Engine with fuel burn .13.

Here is the code: https://github.com/crapo/sadlos2/blob/e34536cf336f10aaeba6c849e2b577ab4e616340/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.jena/src/com/ge/research/sadl/jena/JenaBasedSadlModelProcessor.java#L10241

The problem with your example is that it is not handled by the Jena based SADL model processor. The statement iterator is empty, hence we do not add the required warning. See here: https://github.com/crapo/sadlos2/blob/e34536cf336f10aaeba6c849e2b577ab4e616340/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.jena/src/com/ge/research/sadl/jena/JenaBasedSadlModelProcessor.java#L10238

If I modify the code a bit and add the required warning with a hack, it works:

screencast 2020-03-13 11-32-50

It also works if the same DSL is in a .dialog file. When I implemented it for SADL, I described briefly here, how it works: https://github.com/crapo/sadlos2/pull/393#issue-365237610

crapo commented 4 years ago

I'm a little fuzzy on what would be required for it to actually work for these situations. Is that clear to you? How difficult? (I hadn't seen you first comment when I wrote this. I guess you're fixing it....)

kittaakos commented 4 years ago

Is that clear to you?

Yes, please put a breakpoint here: https://github.com/crapo/sadlos2/blob/e34536cf336f10aaeba6c849e2b577ab4e616340/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.jena/src/com/ge/research/sadl/jena/JenaBasedSadlModelProcessor.java#L10238

With this, it works

uri "http://sadl.org/x.sadl".
Engine is a class described  by sfc (alias "fuel burn") with values of type float.
MyEngine is an Engine with fuel burn .13.

With another example it does not:

uri "http://sadl.org/y.sadl".
PO is a class.
velocity (alias "speed") describes PO with values of type UnittedQuantity.
PO is a class.
MyPo is a PO with speed 23 mph.

How difficult?

The problem is in the model processor. With the first example, the text you want to replace is fuel burn, and the Jena model literal will be fuel burn@en. This is correct. With the second example, the text you want to replace is incorrectly speed 23 mph. The Jena model literal will be speed 23 mph@en. It's wrong. The input should be speed and not speed 23 mph. If I change the variable from speed 23 mph to speed at debug time, it works.

I guess you're fixing it....)

No, I don't. I never change anything in the model processor unless it is necessary. I just figure out it works if the Jena-based model processor puts the desired warning to the model element.