owmeta icon indicating copy to clipboard operation
owmeta copied to clipboard

Add API support for displaying all evidence for a dataObject

Open slarson opened this issue 10 years ago • 6 comments

A dataObject such as a neuron may have a variety of properties. Currently, in order to look up what evidence is associated with a given object, you will have to ask for each property in turn, and look up if there is evidence associated with that property.

If dataObjects supported a .get_evidence() method that took all properties registered with that dataObject and returned a list of evidence associated with whichever property there was, this would make for an easier time interrogating the data.

slarson avatar Aug 24 '15 09:08 slarson

Something like this is very doable. The contexts which make statements about an object will have a statement object rdf:type object_type.

A more precise implementation is also possible by encapsulating queries for each statement and then getting the contexts in which those statements are made. The query_context.py example shows how this can be done.

mwatts15 avatar Feb 28 '19 03:02 mwatts15

The idea is basically to retrieve the contexts for each statement and then to retrieve the evidence for each of those contexts.

I would test what happens when there is no evidence attached to any of the contexts (should return no evidence), test that no evidence object is returned more than once (edited)

Also test what happens when there is no context associated with the object you are querying

Here's an example for an evidence_for function:

>>> c1 = Context(key='c1')
>>> c2 = Context(key='c2')
>>> c3 = Context(key='c3')
>>> evc = Context(key='evc')

>>> c1(Apple)('red-delicious').color('red')
PyOpenWorm.statement.Statement(...)

>>> c1(Apple)('red-delicious').sweetness(7)
PyOpenWorm.statement.Statement(...)

>>> c2(Apple)('red-delicious').sweetness(2)
PyOpenWorm.statement.Statement(...)

>>> ev1 = evc(Evidence)(key='mw2019')
>>> ev1.supports(c1)
PyOpenWorm.statement.Statement(...)

>>> ev2 = evc(Evidence)(key='mw2020')
>>> ev2.supports(c2)
PyOpenWorm.statement.Statement(...)

>>> c3.add_import(c1)
>>> c3.add_import(c2)
>>> c3.add_import(evc)
>>> c3.save()

Get evidence about the Apple 'red-delicious':

>>> for x in evidence_for(Apple('red-delicious'), context=c3.stored):
...     print(x)
Evidence(http://openworm.org/entities/Evidence/mw2019)
Evidence(http://openworm.org/entities/Evidence/mw2020)

Should get the union of contexts for each of the statements for which the given argument is in subject position (at the head of the statement) and then the union of the evidence supporting each of these contexts. Should return an iterable of Evidence objects that support any one of the statements.

I don't care what the function is called as long as it makes sense. I'm against the idea of putting something like a get_evidence on DataObject -- I don't think, for arbitrary DataObject subclasses, that Evidence makes sense since arbitrary objects don't have a scholarly reference which is mainly what Evidence is for.

mwatts15 avatar Mar 10 '19 21:03 mwatts15

Hi, @jaideep-seth .

For the integrity test you will use the integrity test conf, but the setUp method will take care of that for you. readme.conf is just for the sake of the README.md doctests.

Also, just some operational stuff:

  • Generally, you should make comments about code within a pull request on the pull request itself rather than on the issue so we can tie the conversation to the related code and keep the issue comments to progress on the issue as a whole.
  • Please keep to one pull request at a time for a single issue until the work is complete on that part of the solution.

mwatts15 avatar Mar 16 '19 21:03 mwatts15

@mwatts15 , could you please assign me to this issue?

-Thank you!

jaideep-seth avatar Mar 30 '19 21:03 jaideep-seth

  • [x] querying evidence_for with Contexts for statements having/not having an associated Evidence object.
  • [ ] adding support for querying evidence_for for DataObjects other than Contexts holding statements.
  • [ ] adding support for querying evidence_for for Contexts that do have an identifier.

hello @mwatts15, Is this how evidence_for could be queried for Evidence of DataObjects(2nd Checkpoint)? `

from PyOpenWorm.neuron import Neuron neuron = Neuron('AVAL') neuron Neuron(ident=rdflib.term.URIRef('http://openworm.org/entities/Neuron/AVAL'))

for x in evidence_for(neuron): ... print(x) Evidence(http://openworm.org/entities/Evidence/js2019) `

Like evidence_for in evidence.py should the above shown form of evidence_for be added to dataObject.py?

-Thanks!

jaideep-seth avatar Apr 22 '19 17:04 jaideep-seth

That's what it should look like.

mwatts15 avatar Apr 23 '19 02:04 mwatts15