Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_relationship_strength(self, entity):
- try:
- query = str(''' PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
- prefix rn: <http://www.daslab.inf.puc-rio.br/ontologies/RelationshipNotes#>
- select ?relation ?rest ?strength where {{
- ?relation a rn:Relationship.
- ?relation rdf:first <{}>.
- ?relation rdf:rest ?rest.
- ?relation rn:relationshipStrength ?strength.
- }}
- '''.format(entity))
- res = req.get(self.url + up.quote(query), auth=self.auth).json()
- strengths = {}
- for c in res['results']['bindings']:
- strengths[c['rest']['value']] = c['strength']['value']
- return strengths
- except Exception as e:
- Logger.log.error("Cannot query relationship strength, because: " + str(e), exc_info=True)
- return {}
Add Comment
Please, Sign In to add comment