Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
global: updated predicates
Browse files Browse the repository at this point in the history
* Updates the initial predicates that will be used in ClaimStore.
  (closes #8)

Signed-off-by: Jose Benito Gonzalez Lopez <jose.benito.gonzalez@cern.ch>
  • Loading branch information
jbenito3 committed Sep 7, 2015
1 parent 1b198dc commit 228c7f3
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 30 deletions.
10 changes: 4 additions & 6 deletions claimstore/modules/claims/fixtures/predicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ def create_all_predicates():
"""Populate all predicates."""
predicates = [
'is_same_as',
'is_different_than',
'is_erratum_of',
'is_superseded_by',
'is_cited_by',
'is_software_for',
'is_dataset_for'
'is_variant_of',
'is_author_of',
'is_contributor_to',
'is_erratum_of'
]
for pred in predicates:
create_predicate(pred)
8 changes: 5 additions & 3 deletions claimstore/modules/claims/restful.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
# USA.

"""Restful resources for the claims module."""
"""Restful resources for the claims module.
isort:skip_file
"""

from functools import wraps

import isodate # noqa
from flask import Blueprint, request
from flask_restful import Api, Resource, abort, inputs, reqparse
from sqlalchemy import or_

from claimstore.core.datetime import loc_date_utc
Expand All @@ -34,8 +38,6 @@
from claimstore.modules.claims.models import Claim, Claimant, IdentifierType, \
Predicate

from flask_restful import Api, Resource, abort, inputs, reqparse # isort:skip

blueprint = Blueprint(
'claims_restful',
__name__,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"value": "cond-mat/9906097"
},
"claim": {
"predicate": "is_cited_by",
"predicate": "is_variant_of",
"created": "2015-05-25T11:00:00Z",
"certainty": 0.5,
"arguments": {
Expand Down
2 changes: 1 addition & 1 deletion claimstore/modules/claims/static/json/schemas/claim.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"title": "Predicate",
"description": "Type of relation between the subject and the object",
"type": "string",
"enum": ["is_same_as", "is_different_than", "is_erratum_of", "is_superseded_by", "is_cited_by", "is_software_for", "is_dataset_for"]
"enum": ["is_same_as", "is_variant_of", "is_author_of", "is_contributor_to", "is_erratum_of"]
},
"created": {
"title": "Creation datetime",
Expand Down
37 changes: 21 additions & 16 deletions docs/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,34 +70,39 @@ The primary motivation behind ClaimStore was the exchange of
information about persistent identifiers, hence the typical claim
types are:

- ``is_same_as``
- ``is_different_than``
- `is_same_as`: used when there is a 100% equivalence, e.g. a local copy of an
arXiv record, with either the same or enriched metadata, e.g. ORCID
corresponds to this INSPIRE ID
- `is_variant_of`: lesser claim, e.g. arXiv preprint and DOI of a
published paper, e.g. when INSPIRE merges two sources into one

However, the system is generic enough to accept any kind of claims, so
the ClaimStore could be easily used to store information about other
types of relations, such as "is_cited_by" to indicate citation
relations:
the ClaimStore can also be used to store information about other
types of relations, such as:

- ``is_cited_by``
- `is_author_of`: this person is the author of this document
- `is_contributor_to`: this person is supervisor/translator/spokesperson
of this document
- `is_erratum_of`: e.g. if INSPIRE record R1 is variant of DOI1, and DOI2
is erratum of DOI1, but INSPIRE merges all these in the same record,
then there would be three claims: R1 is variant of DOI1, DOI2 is erratum of
DOI1, R1 is variant of DOI2

Examples of other possible relations include errata and superseded
papers:
Examples of other possible relations that could be included in the future
are:

- ``is_erratum_of``
- ``is_cited_by``
- ``is_superseded_by``

or relations between papers, data and software:

- ``is_software_for_paper``
- ``is_dataset_for_paper``
- ``is_dataset_for_software``

For example, imagine the following table of claims::

subject predicate object
-------------------- ----------- -------------------
arXiv:hep-th/0101001 is_same_as DOI:10.1234/foo.bar
arXiv:hep-th/0101001 is_cited_by arXiv:1506.07188
subject predicate object
-------------------- ----------- -------------------
arXiv:hep-th/0101001 is_variant_of DOI:10.1234/foo.bar
arXiv:hep-th/0101001 is_same_as arXiv:1506.07188

One could then ask queries like *who does know about DOI
10.1234/foo.bar?* and the system could return only direct claims::
Expand Down
6 changes: 3 additions & 3 deletions tests/test_restful_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ def test_get_claims_by_claimant(self):
def test_get_claims_by_predicate(self):
"""Testing GET claims filtering by predicate."""
self._populate_all()
# There are 2 claims is_same_as and 1 is_cited_by
# There are 2 claims is_same_as and 1 is_variant_of
resp = self.test_app.get('/claims')
self.assertEqual(len(resp.json), 3)
resp = self.test_app.get('/claims?predicate=is_same_as')
self.assertEqual(len(resp.json), 2)
resp = self.test_app.get('/claims?predicate=is_cited_by')
resp = self.test_app.get('/claims?predicate=is_variant_of')
self.assertEqual(len(resp.json), 1)

def test_get_claims_by_certainty(self):
Expand Down Expand Up @@ -198,4 +198,4 @@ def test_get_predicates(self):
self._populate_all()
resp = self.test_app.get('/predicates')
self.assertEqual(resp.status_code, 200)
self.assertEqual(len(resp.json), 7)
self.assertEqual(len(resp.json), 5)

0 comments on commit 228c7f3

Please sign in to comment.