diff --git a/README.md b/README.md deleted file mode 100644 index f10a197..0000000 --- a/README.md +++ /dev/null @@ -1,99 +0,0 @@ -# sprynger -Simple API wrapper for the [Springer Nature APIs](https://dev.springernature.com). - -![PyPI version](https://badge.fury.io/py/sprynger.svg) -![Python versions](https://img.shields.io/pypi/pyversions/sprynger.svg) -![Documentation Status](https://readthedocs.org/projects/sprynger/badge/?version=latest) -![Downloads](https://img.shields.io/pypi/dm/sprynger.svg) -![License](https://img.shields.io/pypi/l/sprynger.svg) -![Maintainability](https://api.codeclimate.com/v1/badges/1d053321a70d800bfc59/maintainability) - -## 🏔️ Overview Springer Nature -Springer Nature currently offers three APIs: -- **Springer Metadata API:** Metadata of articles, journal articles and book chapters. -- **Springer Meta API:** Advanced version offering versioned metadata. -- **Springer OpenAccess API:** Metadata and, where available, full-text - -## ⬇️ Install - -Download and install the package from PyPI: -```bash -pip install sprynger -``` - -## 🪧 Example Use -
- -### Metadata - -```python -from sprynger import Metadata, init - -init() - -book_metadata = Metadata(isbn='978-3-031-63497-0', nr_results=3) -for chapter in book_metadata: - print(chapter.identifier) - print(chapter.abstract) -``` ->doi:10.1007/978-3-031-63498-7_20 ->> Modern solvers for quantified Boolean formulas (QBFs) process formulas in prenex form, ... - ->doi:10.1007/978-3-031-63498-7_9 ->>Given a finite consistent set of ground literals, we present an algorithm that generates ... - ->doi:10.1007/978-3-031-63498-7_3 ->> The TPTP World is a well established infrastructure that supports research, development, ... - - - -```python -book_metadata.facets -``` ->[MetadataFacets(facet='subject', value='Artificial Intelligence', count='27'),...] - - -### OpenAccess - -```python -from sprynger import OpenAccess -``` - - -```python -results = OpenAccess('"quantum computing"', - dateto='2022-12-30', - type='Journal Article', - nr_results=3) -``` - - -```python -results.documents_found -``` -> 4350 - -```python -for document in results: - print(document.title) - print(document.paragraphs[0].text) -``` -> A neural network assisted ->> A versatile magnetometer must deliver a readable response when exposed to target fields ... - -> Experimental demonstration of classical analogous time-dependent superposition of states ->> One of the quantum theory concepts on which quantum information processing stands is superposition ... - -> A quantum-like cognitive approach to modeling human biased selection behavior ->> Cognitive biases of the human mind significantly influence the human decision-making process ... - -
- -## 📖 Documentation -For a comprehensive guide, see the documentation in [read the docs](https://sprynger.readthedocs.io/en/latest/index.html). - -## ⭐️ Give the package a star -If the package helped you, give it a star! - -## ⚠️ Disclaimer -This project is an independent API wrapper for the Springer Nature API. It is not affiliated with, endorsed, or maintained by Springer Nature. For official support, please refer to the Springers's [documentation](http://docs-dev.springernature.com/docs/) and support channels. diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..28476c9 --- /dev/null +++ b/README.rst @@ -0,0 +1,84 @@ +.. documentation-begin + +sprynger: API wrapper for Springer Nature +============================================ + + +Simple API wrapper for the `Springer Nature APIs `_ + +.. image:: https://badge.fury.io/py/sprynger.svg + :target: https://pypi.org/project/sprynger/ + +.. image:: https://img.shields.io/pypi/pyversions/sprynger.svg + :target: https://pypi.org/project/sprynger/ + +.. image:: https://readthedocs.org/projects/sprynger/badge/?version=latest + :target: https://sprynger.readthedocs.io/en/latest/ + +.. image:: https://img.shields.io/pypi/dm/sprynger.svg + :target: https://pypi.org/project/sprynger/ + +.. image:: https://img.shields.io/pypi/l/sprynger.svg + :target: https://pypi.org/project/sprynger/ + +.. image:: https://api.codeclimate.com/v1/badges/1d053321a70d800bfc59/maintainability + :target: https://codeclimate.com/github/your-repo/sprynger/maintainability + + +🏔️ Overview Springer Nature +---------------------------- + +Springer Nature currently offers three APIs: + +- **Springer Metadata API:** Metadata of articles, journal articles and book chapters. +- **Springer Meta API:** Advanced version offering versioned metadata. +- **Springer OpenAccess API:** Metadata and, where available, full-text. + + +⬇️ Install +----------- +Download and install the package from PyPI: + +.. code-block:: bash + + pip install sprynger + + +🪧 Example Use +--------------- + +.. code:: python + + >>> from sprynger import Meta, OpenAccess, init + >>> init() + >>> + >>> # Get metadata of all chapters in the book with ISBN '978-3-031-63497-0' + >>> book_metadata = Metadata(isbn='978-3-031-63497-0', nr_results=3) + >>> for chapter in book_metadata: + >>> print(chapter.identifier) + >>> print(chapter.abstract) + 'doi:10.1007/978-3-031-63498-7_20' + 'Modern solvers for quantified Boolean formulas (QBFs) process formulas in prenex form, ...' + 'doi:10.1007/978-3-031-63498-7_9' + 'Given a finite consistent set of ground literals, we present an algorithm that generates ...' + 'doi:10.1007/978-3-031-63498-7_3' + 'The TPTP World is a well established infrastructure that supports research, development, ...' + >>> # Print the facets of the retrieved chapter's metadata + >>> book_metadata.facets + [MetadataFacets(facet='subject', value='Artificial Intelligence', count='27'),...] + >>> + >>> # Retrieve full-text of 'journal articles' with the keyword 'quantum computing' published before 2023 + >>> results = OpenAccess('"quantum computing"', dateto='2022-12-30', type='Journal Article', nr_results=3) + >>> results.documents_found + 4350 + >>> for document in results: + >>> print(document.title) + >>> print(document.paragraphs[0].text) + 'A neural network assisted' + 'A versatile magnetometer must deliver a readable response when exposed to target fields ...' + 'Experimental demonstration of classical analogous time-dependent superposition of states' + 'One of the quantum theory concepts on which quantum information processing stands is superposition ...' + 'A quantum-like cognitive approach to modeling human biased selection behavior' + 'Cognitive biases of the human mind significantly influence the human decision-making process ...' + +.. documentation-end \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index b3c78c5..0819b29 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -4,9 +4,9 @@ project = 'sprynger' -copyright = '2024, Nils Herrmann' -author = 'Nils Herrmann' -release = '0.1' +copyright = '2024, Nils A. Herrmann de Alba' +author = 'Nils A. Herrmann de Alba' +release = '0.2.0' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration @@ -17,6 +17,7 @@ 'sphinx.ext.napoleon', # Optional: for Google and NumPy style docstrings 'sphinx_copybutton' ] +copybutton_prompt_text = ">>> " templates_path = ['_templates'] exclude_patterns = [] diff --git a/docs/source/how_to_query.rst b/docs/source/how_to_query.rst index dd1f1dd..4e2f159 100644 --- a/docs/source/how_to_query.rst +++ b/docs/source/how_to_query.rst @@ -4,37 +4,37 @@ How to query ? Querying the API follows the same pattern for all classes. Users can either do **string search** or **specific field search** by passing keyword arguments. Here is an example: -.. code-block:: python +.. code:: python - # String search: Query for documents containing the term "quantum" - results = Meta('quantum') + >>> # String search: Query for documents containing the term "quantum" + >>> results = Meta('quantum') - # Specific field seach: Query for document belonging to the journal with the ISSN 3004-9261 - results = Meta(issn='3004-9261') + >>> # Specific field seach: Query for document belonging to the journal with the ISSN 3004-9261 + >>> results = Meta(issn='3004-9261') There is the option to also pass both a query string and keyword arguments. -.. code-block:: python +.. code:: python - # Query for documents containing the term "'quantum computing'" that where published in 2023 - results = Metadata('"quantum computing"', - datefrom='2023-01-01', - dateto='2023-12-31') + >>> # Query for documents containing the term "'quantum computing'" that where published in 2023 + >>> results = Metadata('"quantum computing"', + >>> datefrom='2023-01-01', + >>> dateto='2023-12-31') Theoretically you can build the complete query as a string. The equivalent query to the above example would be: -.. code-block:: python +.. code:: python - # Query for documents containing the term "'quantum computing'" that where published in 2023 - results = Metadata('"quantum computing" datefrom:2023-01-01 dateto:2023-12-31') + >>> # Query for documents containing the term "'quantum computing'" that where published in 2023 + >>> results = Metadata('"quantum computing" datefrom:2023-01-01 dateto:2023-12-31') Note that each element of the query is separated by a space and the field and values are separated by a colon. Spaces are interpreted as an `AND` operator. The `OR` operator can be used by explicitly stating it. -.. code-block:: python +.. code:: python - # Query for documents containing the term "'quantum computing'" or "'quantum information'" - results = OpenAccess('"quantum computing" OR "quantum information"') + >>> # Query for documents containing the term "'quantum computing'" or "'quantum information'" + >>> results = OpenAccess('"quantum computing" OR "quantum information"') Note that when the query string misses a specific field (e.g. `title`), the search will be performed in all fields. \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index 038cad0..d616efa 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,125 +1,10 @@ -.. sprynger documentation master file, created by - sphinx-quickstart on Fri Sep 13 08:49:46 2024. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. +.. include:: ../../README.rst + :start-after: documentation-begin + :end-before: documentation-end -sprynger: API wrapper for Springer Nature -============================================ .. currentmodule:: sprynger -Simple API wrapper for the `Springer Nature APIs `_ - -.. image:: https://badge.fury.io/py/sprynger.svg - :target: https://pypi.org/project/sprynger/ - -.. image:: https://img.shields.io/pypi/pyversions/sprynger.svg - :target: https://pypi.org/project/sprynger/ - -.. image:: https://readthedocs.org/projects/sprynger/badge/?version=latest - :target: https://sprynger.readthedocs.io/en/latest/ - -.. image:: https://img.shields.io/pypi/dm/sprynger.svg - :target: https://pypi.org/project/sprynger/ - -.. image:: https://img.shields.io/pypi/l/sprynger.svg - :target: https://pypi.org/project/sprynger/ - -.. image:: https://api.codeclimate.com/v1/badges/1d053321a70d800bfc59/maintainability - :target: https://codeclimate.com/github/your-repo/sprynger/maintainability - - -🏔️ Overview Springer Nature ----------------------------- - -Springer Nature currently offers three APIs: - -- **Springer Metadata API:** Metadata of articles, journal articles and book chapters. -- **Springer Meta API:** Advanced version offering versioned metadata. -- **Springer OpenAccess API:** Metadata and, where available, full-text - - -⬇️ Install ------------ -Download and install the package from PyPI: - -.. code-block:: bash - - pip install sprynger - - -🪧 Example Use ---------------- - -Metadata -^^^^^^^^^^^^ - -.. code-block:: python - - from sprynger import Metadata, init - - init() - - book_metadata = Metadata(isbn='978-3-031-63497-0', nr_results=3) - for chapter in book_metadata: - print(chapter.identifier) - print(chapter.abstract) - -.. code-block:: text - - doi:10.1007/978-3-031-63498-7_20 - Modern solvers for quantified Boolean formulas (QBFs) process formulas in prenex form, ... - - doi:10.1007/978-3-031-63498-7_9 - Given a finite consistent set of ground literals, we present an algorithm that generates ... - - doi:10.1007/978-3-031-63498-7_3 - The TPTP World is a well established infrastructure that supports research, development, ... - -.. code-block:: python - - book_metadata.facets - -.. code-block:: text - - [MetadataFacets(facet='subject', value='Artificial Intelligence', count='27'),...] - -OpenAccess -^^^^^^^^^^^^ - -.. code-block:: python - - from sprynger import OpenAccess - - results = OpenAccess('"quantum computing"', - dateto='2022-12-30', - type='Journal Article', - nr_results=3) - - results.documents_found - - -.. code-block:: text - - 4350 - -.. code-block:: python - - for document in results: - print(document.title) - print(document.paragraphs[0].text) - -.. code-block:: text - - A neural network assisted - A versatile magnetometer must deliver a readable response when exposed to target fields ... - - Experimental demonstration of classical analogous time-dependent superposition of states - One of the quantum theory concepts on which quantum information processing stands is superposition ... - - A quantum-like cognitive approach to modeling human biased selection behavior - Cognitive biases of the human mind significantly influence the human decision-making process ... - .. toctree:: :maxdepth: 1 diff --git a/docs/source/initialization.rst b/docs/source/initialization.rst index f7ad663..3d5de89 100644 --- a/docs/source/initialization.rst +++ b/docs/source/initialization.rst @@ -3,11 +3,11 @@ Start-up You initalize `sprynger` as follows: -.. code-block:: python +.. code:: python - import sprynger + >>> import sprynger - sprynger.init() + >>> sprynger.init() This reads the configuration from the default locations. You may also specify a different configuration file and API keys: @@ -25,7 +25,7 @@ This reads the configuration from the default locations. You may also specify a **Example**: - .. code-block:: python + .. code:: python >>> from sprynger import init >>> init(config_dir='path/to/custom/config.cfg', keys=['key1', 'key2']) diff --git a/pyproject.toml b/pyproject.toml index bedf092..f9d0740 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,12 +4,12 @@ build-backend = "setuptools.build_meta" [project] name = "sprynger" -version = "0.1.0" +version = "0.2.0" authors = [ { name="Nils Herrmann", email="nils_herrmann@outlook.de" }, ] description = "An API wrapper for Springer Nature" -readme = "README.md" +readme = "README.rst" requires-python = ">=3.9" dependencies = ["lxml", "requests", "urllib3"] keywords = ["API", "Springer", "wrapper", "requests", "lxml"] diff --git a/sprynger/tests/test_meta.py b/sprynger/tests/test_meta.py index 225b95d..90b834f 100644 --- a/sprynger/tests/test_meta.py +++ b/sprynger/tests/test_meta.py @@ -23,59 +23,59 @@ def test_results(): def test_records(): """Test the records.""" expected_record = MetaRecord( - contentType='Article', - identifier='doi:10.1007/s00394-024-03496-7', - language='en', + contentType="Article", + identifier="doi:10.1007/s00394-024-03496-7", + language="en", urls=[ MetaURL( - format='html', - platform='web', - value='http://link.springer.com/openurl/fulltext?id=doi:10.1007/s00394-024-03496-7', + format="html", + platform="web", + value="http://link.springer.com/openurl/fulltext?id=doi:10.1007/s00394-024-03496-7", ), MetaURL( - format='pdf', - platform='web', - value='http://link.springer.com/openurl/pdf?id=doi:10.1007/s00394-024-03496-7', + format="pdf", + platform="web", + value="http://link.springer.com/openurl/pdf?id=doi:10.1007/s00394-024-03496-7", ), MetaURL( - format='', - platform='', - value='http://dx.doi.org/10.1007/s00394-024-03496-7', + format="", + platform="", + value="http://dx.doi.org/10.1007/s00394-024-03496-7", ), ], - title='Ultra-processed food intake in toddlerhood and mid-childhood in the UK: cross sectional and longitudinal perspectives', + title="Ultra-processed food intake in toddlerhood and mid-childhood in the UK: cross sectional and longitudinal perspectives", creators=[ - MetadataCreator(creator='Conway, Rana E.', ORCID='0000-0003-0955-7107'), - MetadataCreator(creator='Heuchan, Gabriella N.', ORCID=None), - MetadataCreator(creator='Heggie, Lisa', ORCID='0000-0002-4846-2357'), - MetadataCreator(creator='Rauber, Fernanda', ORCID='0000-0001-9693-7954'), - MetadataCreator(creator='Lowry, Natalie', ORCID='0000-0002-9137-5005'), - MetadataCreator(creator='Hallen, Hannah', ORCID=None), - MetadataCreator(creator='Llewellyn, Clare H.', ORCID='0000-0002-0066-2827'), + MetadataCreator(creator="Conway, Rana E.", ORCID="0000-0003-0955-7107"), + MetadataCreator(creator="Heuchan, Gabriella N.", ORCID=None), + MetadataCreator(creator="Heggie, Lisa", ORCID="0000-0002-4846-2357"), + MetadataCreator(creator="Rauber, Fernanda", ORCID="0000-0001-9693-7954"), + MetadataCreator(creator="Lowry, Natalie", ORCID="0000-0002-9137-5005"), + MetadataCreator(creator="Hallen, Hannah", ORCID=None), + MetadataCreator(creator="Llewellyn, Clare H.", ORCID="0000-0002-0066-2827"), ], - publicationName='European Journal of Nutrition', + publicationName="European Journal of Nutrition", openaccess=True, - doi='10.1007/s00394-024-03496-7', - publisher='Springer', - publicationDate='2024-10-04', - publicationType='Journal', - issn='1436-6207', - eIssn='1436-6215', - volume='', - number='', - issueType='', - topicalCollection='', - genre=['OriginalPaper', 'Original Contribution'], - startingPage=1, - endingPage=12, + doi="10.1007/s00394-024-03496-7", + publisher="Springer", + publicationDate="2024-12-01", + publicationType="Journal", + issn="1436-6207", + eIssn="1436-6215", + volume=63, + number=8, + issueType="Regular", + topicalCollection="", + genre=["OriginalPaper", "Original Contribution"], + startingPage=3149, + endingPage=3160, journalId=394, - onlineDate='2024-10-04', - copyright='©2024 The Author(s)', - abstract='Purpose (i) Characterize ultra-processed food (UPF) intakes in toddlerhood and mid-childhood, including identifying principal UPF sub-groups and associations with nutrient profile; (ii) explore stability and change in UPF intake between toddlerhood and mid-childhood. Methods Data were from children in the UK Gemini twin cohort at 21 months ( n \u2009=\u20092,591) and 7 years ( n \u2009=\u2009592) of age. UPF intakes were estimated using diet diaries and Nova classification. Complex samples general linear or logistic regression models were used to explore associations between UPF intake, UPF sub-groups and nutrients, and changes in intake over time. Results The contribution of UPF to total energy was 46.9% (±\u200914.7) at 21 months and 59.4% (±\u200912.5) at 7 years. Principal UPF sub-groups were yogurts, higher-fiber breakfast cereals, and wholegrain breads in toddlerhood, and puddings and sweet cereal products and white breads in mid-childhood. At both ages, mean free sugar and sodium intakes exceeded recommended maximums and higher UPF consumption was associated with consuming more of each nutrient ( P \u2009<\u20090.001). UPF intake was negatively associated with fat, saturated fat and protein intake in toddlerhood, and fiber intake in mid-childhood ( P \u2009<\u20090.001). Being in the highest UPF intake quintile in toddlerhood was predictive of being in the highest quintile in mid-childhood (OR 9.40, 95%CI 3.94–22.46). Conclusions UPF accounted for nearly half of toddlers’ energy, increasing to 59% in mid-childhood. Higher UPF consumers had higher intakes of free sugar and sodium. UPF intake in toddlerhood was predictive of mid-childhood intake. Effective policies are needed to reduce UPF intakes in the early years.', + onlineDate="2024-10-04", + copyright="©2024 The Author(s)", + abstract="Purpose (i) Characterize ultra-processed food (UPF) intakes in toddlerhood and mid-childhood, including identifying principal UPF sub-groups and associations with nutrient profile; (ii) explore stability and change in UPF intake between toddlerhood and mid-childhood. Methods Data were from children in the UK Gemini twin cohort at 21 months ( n \u2009=\u20092,591) and 7 years ( n \u2009=\u2009592) of age. UPF intakes were estimated using diet diaries and Nova classification. Complex samples general linear or logistic regression models were used to explore associations between UPF intake, UPF sub-groups and nutrients, and changes in intake over time. Results The contribution of UPF to total energy was 46.9% (±\u200914.7) at 21 months and 59.4% (±\u200912.5) at 7 years. Principal UPF sub-groups were yogurts, higher-fiber breakfast cereals, and wholegrain breads in toddlerhood, and puddings and sweet cereal products and white breads in mid-childhood. At both ages, mean free sugar and sodium intakes exceeded recommended maximums and higher UPF consumption was associated with consuming more of each nutrient ( P \u2009<\u20090.001). UPF intake was negatively associated with fat, saturated fat and protein intake in toddlerhood, and fiber intake in mid-childhood ( P \u2009<\u20090.001). Being in the highest UPF intake quintile in toddlerhood was predictive of being in the highest quintile in mid-childhood (OR 9.40, 95%CI 3.94–22.46). Conclusions UPF accounted for nearly half of toddlers’ energy, increasing to 59% in mid-childhood. Higher UPF consumers had higher intakes of free sugar and sodium. UPF intake in toddlerhood was predictive of mid-childhood intake. Effective policies are needed to reduce UPF intakes in the early years.", conferenceInfo=[], - keyword=['Ultra-processed foods', 'Diet quality', 'Toddlers', 'Children', 'UK'], - subjects=['Chemistry', 'Nutrition'], - disciplines=[MetaDiscipline(id='3524', term='Nutrition')], + keyword=["Ultra-processed foods", "Diet quality", "Toddlers", "Children", "UK"], + subjects=["Chemistry", "Nutrition"], + disciplines=[MetaDiscipline(id="3524", term="Nutrition")], ) assert article.records[0] == expected_record