diff --git a/biokb/setup.py b/biokb/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..ada1b5cf22c9bf7701b1fba2e0fbee9ca6a127a7 --- /dev/null +++ b/biokb/setup.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +try: + from setuptools import setup, find_packages +except ImportError: + from distutils.core import setup + +requirements = [ + 'SPARQLWrapper==1.8.4', + 'rdflib==4.2.2' +] + +test_requirements = [ + 'coverage' +] + +setup( + name='textminingservice-biokb', + version='0.0.1', + description="BioKB implementation of the common text mining interface", + url='', + packages=find_packages(exclude=['contrib', 'docs', 'tests*']), + package_dir={'textminingservice-biokb': + 'textminingservice_biokb'}, + include_package_data=True, + install_requires=requirements, + zip_safe=False, + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Natural Language :: English', + 'Programming Language :: Python :: 3.7', + ], + tests_require=test_requirements, +) diff --git a/integration/__init__.py b/biokb/textminingservice_biokb/__init__.py similarity index 100% rename from integration/__init__.py rename to biokb/textminingservice_biokb/__init__.py diff --git a/biokb/biokb.py b/biokb/textminingservice_biokb/biokb.py similarity index 91% rename from biokb/biokb.py rename to biokb/textminingservice_biokb/biokb.py index 38a63334eaeb604819e5d39a0e6c99aee8d57b02..1b0aecfb59fce3dd8d03c2cbf909add58a455aef 100644 --- a/biokb/biokb.py +++ b/biokb/textminingservice_biokb/biokb.py @@ -4,10 +4,10 @@ from typing import List from SPARQLWrapper import SPARQLWrapper, JSON, POSTDIRECTLY from SPARQLWrapper.SPARQLExceptions import QueryBadFormed -from interface.TextMiningService import TextMiningService -from models.coocurrence import CoOccurrence -from models.publication import Publication -from .utils import uri_to_entity_code, standarise_underscored_entity_code +from textminingservice.TextMiningService import TextMiningService +from textminingservice.models.coocurrence import CoOccurrence +from textminingservice.models.publication import Publication +from textminingservice_biokb.utils import uri_to_entity_code, standardise_underscored_entity_code logger = logging.getLogger(__name__) @@ -41,7 +41,7 @@ class BioKBService(TextMiningService): entity_subquery = "" for entity in entities: - entity = standarise_underscored_entity_code(entity) + entity = standardise_underscored_entity_code(entity) entity_subquery += f"?publication <http://lcsb.uni.lu/biokb#containsEntity> <http://lcsb.uni.lu/biokb/entities/{entity}> .\n" query = """ @@ -70,7 +70,7 @@ class BioKBService(TextMiningService): types_str = ', '.join((f'<{t}>' for t in types)) entity_types_filter = f'FILTER (?e_type IN ({types_str}) )' - entity = standarise_underscored_entity_code(entity) + entity = standardise_underscored_entity_code(entity) query = """ select * where { diff --git a/biokb/utils.py b/biokb/textminingservice_biokb/utils.py similarity index 85% rename from biokb/utils.py rename to biokb/textminingservice_biokb/utils.py index 270a7ec7c695b12f3b9c59864c28549972db5205..921cd4b672f12f02c8285f22ea0aaa120894eb3b 100644 --- a/biokb/utils.py +++ b/biokb/textminingservice_biokb/utils.py @@ -1,4 +1,4 @@ -def standarise_underscored_entity_code(entity_code: str) -> str: +def standardise_underscored_entity_code(entity_code: str) -> str: return entity_code.replace(':', '_', 1) diff --git a/dummy-service/__init__.py b/dummy-service/__init__.py deleted file mode 100644 index c7dec7f2c5973b985c22ed0f20cf8ee2f9cba909..0000000000000000000000000000000000000000 --- a/dummy-service/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/dummy-service/setup.py b/dummy-service/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..c1ce58a9ea46de52ef10a88366a130f11923ae5d --- /dev/null +++ b/dummy-service/setup.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +try: + from setuptools import setup, find_packages +except ImportError: + from distutils.core import setup + +requirements = [ + +] + +test_requirements = [ + 'coverage' +] + +setup( + name='textminingservice-dummy', + version='0.0.1', + description="Dummy implementation of the common text mining interface", + url='', + packages=find_packages(exclude=['contrib', 'docs', 'tests*']), + package_dir={'textminingservice-dummy': + 'textminingservice_dummy'}, + include_package_data=True, + install_requires=requirements, + zip_safe=False, + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Natural Language :: English', + 'Programming Language :: Python :: 3.7', + ], + tests_require=test_requirements, +) diff --git a/jensenLabService/__init__.py b/dummy-service/textminingservice_dummy/__init__.py similarity index 100% rename from jensenLabService/__init__.py rename to dummy-service/textminingservice_dummy/__init__.py diff --git a/dummy-service/dummyService.py b/dummy-service/textminingservice_dummy/dummyService.py similarity index 82% rename from dummy-service/dummyService.py rename to dummy-service/textminingservice_dummy/dummyService.py index 6a9c16d59b84bee92d71fcc21a1ca08b92a25357..7c91ea8373fab4d8fe489efc489bfed79819e0a2 100644 --- a/dummy-service/dummyService.py +++ b/dummy-service/textminingservice_dummy/dummyService.py @@ -1,8 +1,9 @@ import logging from typing import List -from interface.TextMiningService import TextMiningService, Publication -from models.coocurrence import CoOccurrence +from textminingservice.TextMiningService import TextMiningService +from textminingservice.models.coocurrence import CoOccurrence +from textminingservice.models.publication import Publication logger = logging.getLogger(__name__) @@ -18,7 +19,7 @@ class DummyService(TextMiningService): values = [] for idx in range(limit): entity_code = f'{entity}_{idx}' - count = int(idx*idx) + count = int(idx * idx) co_occur = CoOccurrence(entity_code, count) values.append(co_occur) return values diff --git a/integration/setup.py b/integration/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..95e516bdc79e09ea2ce754404c8331c2805ae1ab --- /dev/null +++ b/integration/setup.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +try: + from setuptools import setup, find_packages +except ImportError: + from distutils.core import setup + +requirements = [ + +] + +test_requirements = [ + 'coverage' +] + +setup( + name='textminingservice-integration', + version='0.0.1', + description="Example of integrations of several text-mining services", + url='', + packages=find_packages(exclude=['contrib', 'docs', 'tests*']), + package_dir={'textminingservice-integration': + 'textminingservice_integration'}, + include_package_data=True, + install_requires=requirements, + zip_safe=False, + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Natural Language :: English', + 'Programming Language :: Python :: 3.7', + ], + tests_require=test_requirements, +) diff --git a/integration/textminingservice_integration/__init__.py b/integration/textminingservice_integration/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9c847747453665c332c6dd80107c138189275a80 --- /dev/null +++ b/integration/textminingservice_integration/__init__.py @@ -0,0 +1,4 @@ +import logging + +logger = logging.getLogger(__name__) + \ No newline at end of file diff --git a/integration/example.py b/integration/textminingservice_integration/example.py similarity index 59% rename from integration/example.py rename to integration/textminingservice_integration/example.py index 43e1a0c0a7ac7a27dabf5fa31c4f89d90a428b8b..a8fc381f5cf5f3e559dd400b7c7191afb02257aa 100644 --- a/integration/example.py +++ b/integration/textminingservice_integration/example.py @@ -1,12 +1,8 @@ -import logging - -from biokb.biokb import BioKBService -from jensenLabService.jensenLabService import JensenLabService - -logger = logging.getLogger(__name__) +from textminingservice_biokb.biokb import BioKBService +from textminingservice_dummy.dummyService import DummyService if __name__ == '__main__': - text_mining_services = [JensenLabService(), BioKBService()] + text_mining_services = [DummyService(), BioKBService()] for text_mining_service in text_mining_services: print("Using service {}".format(text_mining_service.name)) publications = text_mining_service.get_mentions( diff --git a/interface/__init__.py b/interface/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/interface/setup.py b/interface/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..63cb137a04091d4fec6a6d204aa2be0da3ab07d0 --- /dev/null +++ b/interface/setup.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +try: + from setuptools import setup, find_packages +except ImportError: + from distutils.core import setup + +requirements = [ + +] + +test_requirements = [ + 'coverage' +] + +setup( + name='textminingservice-interface', + version='0.0.1', + description="Provides common interface to several text-mining services", + url='', + packages=find_packages(exclude=['contrib', 'docs', 'tests*']), + package_dir={'textminingservice': + 'textminingservice'}, + include_package_data=True, + install_requires=requirements, + zip_safe=False, + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Natural Language :: English', + 'Programming Language :: Python :: 3.7', + ], + tests_require=test_requirements, +) diff --git a/interface/TextMiningService.py b/interface/textminingservice/TextMiningService.py similarity index 89% rename from interface/TextMiningService.py rename to interface/textminingservice/TextMiningService.py index 2c2ac4df901ab1dd6c6a6b2ca079c48ea73a11af..88385ab28a3c95d7fa59c70578e0156044c2d5c7 100644 --- a/interface/TextMiningService.py +++ b/interface/textminingservice/TextMiningService.py @@ -1,8 +1,8 @@ from abc import ABCMeta, abstractmethod from typing import List -from models.coocurrence import CoOccurrence -from models.publication import Publication +from textminingservice.models.coocurrence import CoOccurrence +from textminingservice.models.publication import Publication class TextMiningService(metaclass=ABCMeta): diff --git a/interface/textminingservice/__init__.py b/interface/textminingservice/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9c847747453665c332c6dd80107c138189275a80 --- /dev/null +++ b/interface/textminingservice/__init__.py @@ -0,0 +1,4 @@ +import logging + +logger = logging.getLogger(__name__) + \ No newline at end of file diff --git a/biokb/__init__.py b/interface/textminingservice/models/__init__.py similarity index 100% rename from biokb/__init__.py rename to interface/textminingservice/models/__init__.py diff --git a/models/coocurrence.py b/interface/textminingservice/models/coocurrence.py similarity index 100% rename from models/coocurrence.py rename to interface/textminingservice/models/coocurrence.py diff --git a/models/publication.py b/interface/textminingservice/models/publication.py similarity index 100% rename from models/publication.py rename to interface/textminingservice/models/publication.py diff --git a/jensenLabService/setup.py b/jensenLabService/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..a326077591c725d0298ef81af59c56cd6d08f357 --- /dev/null +++ b/jensenLabService/setup.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +try: + from setuptools import setup, find_packages +except ImportError: + from distutils.core import setup + +requirements = [ + +] + +test_requirements = [ + 'coverage' +] + +setup( + name='textminingservice-jensenlab', + version='0.0.1', + description="jensenlab implementation of the common text mining interface", + url='', + packages=find_packages(exclude=['contrib', 'docs', 'tests*']), + package_dir={'textminingservice-jensenlab': + 'textminingservice_jensenlab'}, + include_package_data=True, + install_requires=requirements, + zip_safe=False, + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Natural Language :: English', + 'Programming Language :: Python :: 3.7', + ], + tests_require=test_requirements, +) diff --git a/jensenLabService/textminingservice_jensenlab/__init__.py b/jensenLabService/textminingservice_jensenlab/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9c847747453665c332c6dd80107c138189275a80 --- /dev/null +++ b/jensenLabService/textminingservice_jensenlab/__init__.py @@ -0,0 +1,4 @@ +import logging + +logger = logging.getLogger(__name__) + \ No newline at end of file diff --git a/jensenLabService/jensenLabService.py b/jensenLabService/textminingservice_jensenlab/jensenlabservice.py similarity index 95% rename from jensenLabService/jensenLabService.py rename to jensenLabService/textminingservice_jensenlab/jensenlabservice.py index a30eeaafa4b6d4de4d893a6506d53c6c842dbd91..54365fa57639547954e681c2af1a2ad987489e92 100644 --- a/jensenLabService/jensenLabService.py +++ b/jensenLabService/textminingservice_jensenlab/jensenlabservice.py @@ -4,8 +4,8 @@ from typing import List import requests -from interface.TextMiningService import TextMiningService -from models.publication import Publication +from textminingservice.TextMiningService import TextMiningService +from textminingservice.models.publication import Publication logger = logging.getLogger(__name__) diff --git a/models/__init__.py b/models/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 1ae881a0c2f17e73961ceb947aa5443cd29cc50c..0000000000000000000000000000000000000000 --- a/requirements.txt +++ /dev/null @@ -1,15 +0,0 @@ -astroid==2.3.3 -autopep8==1.4.4 -isodate==0.6.0 -isort==4.3.21 -lazy-object-proxy==1.4.3 -mccabe==0.6.1 -pep8==1.7.1 -pycodestyle==2.5.0 -pylint==2.4.4 -pyparsing==2.4.5 -rdflib==4.2.2 -six==1.13.0 -SPARQLWrapper==1.8.4 -typed-ast==1.4.0 -wrapt==1.11.2