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

fixed imports and renamed folders

parent a336c560
No related branches found
No related tags found
No related merge requests found
File moved
...@@ -4,7 +4,8 @@ from typing import List ...@@ -4,7 +4,8 @@ from typing import List
import requests import requests
from TextMiningService import TextMiningService, Publication from interface.TextMiningService import TextMiningService
from models.publication import Publication
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -30,7 +31,8 @@ class JensenLabService(TextMiningService): ...@@ -30,7 +31,8 @@ class JensenLabService(TextMiningService):
else: else:
limit_per_entity = JensenLabService.LIMIT_PER_ENTITY limit_per_entity = JensenLabService.LIMIT_PER_ENTITY
for (entity, entity_type) in entities_and_types: for (entity, entity_type) in entities_and_types:
publications_ids.append(self.get_mentions_for_entity(entity, entity_type, limit=limit_per_entity)) publications_ids.append(self.get_mentions_for_entity(
entity, entity_type, limit=limit_per_entity))
publications_ids_intersection = set.intersection(*publications_ids) publications_ids_intersection = set.intersection(*publications_ids)
return [Publication(pm_id=pid) for pid in publications_ids_intersection][0:limit] return [Publication(pm_id=pid) for pid in publications_ids_intersection][0:limit]
...@@ -54,7 +56,8 @@ class JensenLabService(TextMiningService): ...@@ -54,7 +56,8 @@ class JensenLabService(TextMiningService):
@staticmethod @staticmethod
def get_mentions_for_entity(entity, entity_type, limit): def get_mentions_for_entity(entity, entity_type, limit):
url_mentions = JensenLabService.MENTION_URL.format(entity_type, entity, limit) url_mentions = JensenLabService.MENTION_URL.format(
entity_type, entity, limit)
results = requests.get(url_mentions) results = requests.get(url_mentions)
assert results.ok assert results.ok
publications_string = results.content.decode().strip() publications_string = results.content.decode().strip()
...@@ -65,5 +68,6 @@ class JensenLabService(TextMiningService): ...@@ -65,5 +68,6 @@ class JensenLabService(TextMiningService):
if __name__ == '__main__': if __name__ == '__main__':
text_mining_service = JensenLabService() text_mining_service = JensenLabService()
print("Using service {}".format(text_mining_service.name)) print("Using service {}".format(text_mining_service.name))
publications = text_mining_service.get_mentions(["DOID:10652", "DOID:10935"], limit=1000000) publications = text_mining_service.get_mentions(
["DOID:10652", "DOID:10935"], limit=1000000)
print(", ".join([p.pm_id for p in publications])) print(", ".join([p.pm_id for p in publications]))
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