Skip to content
Snippets Groups Projects
Commit ad389e25 authored by Carlos Vega's avatar Carlos Vega
Browse files

retrieve publication details from solr repository using solr ids from biokb virtuoso triple store

parent f3aaafec
No related branches found
No related tags found
No related merge requests found
......@@ -51,19 +51,35 @@ class BioKBService(TextMiningService):
query = """
select ?publication str(?solrId) as ?solrId where {{
{}
{}
?publication <http://lcsb.uni.lu/biokb#solrId> ?solrId .
}} LIMIT {}
""".format(entity_subquery, limit)
results = self._run_sparql_query(query)
values = []
solr_ids = set()
for result in results['results']['bindings']:
solr_id = result['solrId']['value']
pub = Publication(other_id=solr_id)
values.append(pub)
return values
solr_ids.add(solr_id)
# pub = Publication(other_id=solr_id)
# solr_ids[solr_id] = pub
# translate ids
response = requests.get(BioKBService.SOLR_TRANSLATOR_URL,
data={'solrIds': solr_ids})
assert response.ok
data = json.loads(response.content.decode().strip())
publications = []
for pub in data['publications']:
p = Publication(title=pub.get('title', None),
journal_title=pub.get('journal_title', None),
doi=pub.get('doi', None),
pm_id=pub.get('pubmed_id', None),
pmc_id=pub.get('pmc_id', None),
other_id=pub['id'],
year=pub.get('year', None))
publications.append(p)
return publications
def get_co_occurrences(self, entity: str, limit: int = 20, types: List[str] = None) -> List[CoOccurrence]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment