Exemple #1
0
    def test_award_affil(self):
        query = self.spaql_templates.award_affiliations()
        res = list(self.graph.query(query))
        out = {}
        for award, affil in res:
            award = self.nsm._qhrm(award)
            if isinstance(affil, rdflib.URIRef):
                ror = idlib.Ror(affil)
                affil = f'{ror.identifier.curie} ({ror.label})'
            else:
                continue  # skip these for now
                affil = affil.toPython()

            if award not in out:
                out[award] = []

            out[award].append(affil)

        for k, vs in sorted(out.items()):
            vs.sort()
            print(k)
            [print('\t', v) for v in vs]

        print('unique awards:', len(out))
        print('unique affils:',
              len(set([v for vs in out.values() for v in vs])))
        self.pp(res, unpack=False)
        assert len(res) > 0
 def affiliation(self, value):
     #_, s = self.c.affiliation(value)
     try:
         if isinstance(value, str):  # FIXME json conv
             yield from idlib.Ror(value).triples_gen
         else:
             yield from value.triples_gen
     except idlib.exc.RemoteError as e:
         # FIXME sigh, temp until we can split out the
         # remote data resolution phase from the rest
         loge.exception(e)
Exemple #3
0
    def __new__(cls, something):
        if '10.' in something:
            if 'http' in something and 'doi.org' not in something:
                pass  # probably a publisher uri that uses the handle
            else:
                return idlib.Doi(something)

        if 'orcid' in something:
            return idlib.Orcid(something)

        if '/ror.org/' in something or something.startswith('ror:'):
            return idlib.Ror(something)

        if 'protocols.io' in something:
            return idlib.Pio(something)

        return oq.OntId(something)
        return OntTerm(something)  # use the better local version of OntTerm
Exemple #4
0
 def affiliation(self, value):
     #_, s = self.c.affiliation(value)
     if isinstance(value, str):  # FIXME json conv
         yield from idlib.Ror(value).triples_gen
     else:
         yield from value.triples_gen
Exemple #5
0
 def mapping(self):
     return {a:idlib.Ror(r) if r else None
             for a, r in zip(self.byCol.affiliation_string,
                             self.byCol.ror_id)}
Exemple #6
0
 def test_asType(self):
     import rdflib
     from idlib.formats import rdf as _bind_rdf
     r = idlib.Ror(self.ids[0])
     nt = r.asType(rdflib.URIRef)
     assert str(r) != str(nt), 'string representation of streams should not match id'
Exemple #7
0
 def test_triples(self):
     from idlib.formats import rdf as _bind_rdf
     r = idlib.Ror(self.ids[0])
     trips = list(r.triples_gen)
Exemple #8
0
 def ror_id(row):
     r = row.ror_id().value
     return idlib.Ror(r) if r else None