{"id":34082735,"url":"https://github.com/gnames/pygnparser","last_synced_at":"2026-04-06T09:01:36.095Z","repository":{"id":230086626,"uuid":"777901456","full_name":"gnames/pygnparser","owner":"gnames","description":"A Python wrapper for GNparser","archived":false,"fork":false,"pushed_at":"2024-11-12T19:40:36.000Z","size":59,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-12-16T14:46:51.804Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gnames.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-26T18:01:56.000Z","updated_at":"2024-11-12T19:40:39.000Z","dependencies_parsed_at":"2024-03-27T19:43:32.331Z","dependency_job_id":"f06e7e38-0926-43e4-8fe1-fa8644012ffc","html_url":"https://github.com/gnames/pygnparser","commit_stats":null,"previous_names":["gnames/pygnparser"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/gnames/pygnparser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnames%2Fpygnparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnames%2Fpygnparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnames%2Fpygnparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnames%2Fpygnparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gnames","download_url":"https://codeload.github.com/gnames/pygnparser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnames%2Fpygnparser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31466228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T08:36:52.050Z","status":"ssl_error","status_checked_at":"2026-04-06T08:36:51.267Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-14T12:24:38.649Z","updated_at":"2026-04-06T09:01:36.082Z","avatar_url":"https://github.com/gnames.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyGNparser\n\n[![PyPI version](https://img.shields.io/pypi/v/pygnparser.svg)](https://pypi.python.org/pypi/pygnparser) [![Python workflow](https://github.com/gnames/pygnparser/workflows/Python/badge.svg)](https://github.com/gnames/pygnparser/actions?query=workflow%3APython)\n\nThis is a Python wrapper on the [GNparser](https://parser.globalnames.org/) API. Code follow the spirit/approach of the [pygbif](https://github.com/gbif/pygbif/graphs/contributors) package, and indeed much of the wrapping utility is copied 1:1 from that repo, thanks [@sckott](https://github.com/sckott) and other [contributors](https://github.com/gbif/pygbif/graphs/contributors).\n\n## Installation\n\nAdd this line to your application's requirements.txt:\n\n```python\npygnparser\n```\n\nAnd then execute:\n\n    $ pip install -r requirements.txt\n\nOr install it yourself as:\n\n    $ pip install pygnparser\n\n## Usage\n\n\nImport the library:\n```\nfrom pygnparser import gnparser\n```\n\nIf you have a local installation of gnparser, set the GNPARSER_BASE_URL to the host and port that the service is running on, for example if running locally on port 8787:\n\n```python\nGNPARSER_BASE_URL = \"http://localhost:8787/\"\n```\n\nWithout the GNPARSER_BASE_URL environment variable set, the wrapper will default to using the remote API which will perform slower: https://parser.globalnames.org/\n\n\n---\n### Parse a scientific name\nParse a scientific name:\n```python\n\u003e\u003e\u003e result = gnparser('Ursus arctos Linnaeus, 1758') #  =\u003e Dictionary\n```\n\nCheck if parsed:\n```python\n\u003e\u003e\u003e result.parsed() #  =\u003e Boolean\nTrue\n```\n\nGet [parsed quality](https://github.com/gnames/gnparser#figuring-out-if-names-are-well-formed):\n```python\n\u003e\u003e\u003e result.quality() #  =\u003e Integer\n1\n```\n\nGet the genus name:\n```python\n\u003e\u003e\u003e result.genus() #  =\u003e String\n'Ursus'\n```\n\nGet the species name:\n```python\n\u003e\u003e\u003e result.species() #  =\u003e String\n'arctos'\n```\n\nGet the year:\n```python\n\u003e\u003e\u003e result.year() #  =\u003e String\n'1758'\n```\n\nGet the authorship:\n```python\n\u003e\u003e\u003e result.authorship() #  =\u003e String\n'(Linnaeus, 1758)'\n```\n\nGet the scientific name without the Latin gender stem:\n```python\n\u003e\u003e\u003e result.canonical_stemmed() #  =\u003e String\n'Ursus arct'\n```\n\nGet the parsed name components for a hybrid formula:\n```python\n\u003e\u003e\u003e result = gnparser('Isoetes lacustris × stricta Gay') #  =\u003e Dictionary\n\u003e\u003e\u003e result.is_hybrid() #  =\u003e Boolean\nTrue\n\u003e\u003e\u003e result.hybrid() #  =\u003e String\n'HYBRID_FORMULA'\n\u003e\u003e\u003e result.normalized() #  =\u003e String\n'Isoetes lacustris × Isoetes stricta Gay'\n\u003e\u003e\u003e result.hybrid_formula_ranks() #  =\u003e Array\n['species', 'species']\n\u003e\u003e\u003e res.hybrid_formula_genera() #  =\u003e Array\n['Isoetes', 'Isoetes']\n\u003e\u003e\u003e res.hybrid_formula_species() #  =\u003e Array\n['lacustris', 'stricta']\n\u003e\u003e\u003e res.hybrid_formula_authorship() #  =\u003e Array\n['', 'Gay']\n```\n\nParse a scientific name under a specified nomenclatural code:\n```python\n\u003e\u003e\u003e result = gnparser('Malus domestica \\'Fuji\\'', code='cultivar')\n\u003e\u003e\u003e result.is_cultivar() #  =\u003e Boolean\nTrue\n\u003e\u003e\u003e result.genus() #  =\u003e String\n'Malus'\n\u003e\u003e\u003e result.species() #  =\u003e String\n'domestica'\n\u003e\u003e\u003e result.cultivar() #  =\u003e String\n'‘Fuji’'\n\u003e\u003e\u003e result.nomenclatural_code() #  =\u003e String\n'ICNCP'\n```\n\n---\n### Parse multiple scientific names\nParse multiple scientific names by separating them with `\\r\\n`:\n```python\nresults = gnparser('Ursus arctos Linnaeus, 1758\\r\\nAlces alces (Linnaeus, 1758)\\r\\nRangifer tarandus (Linnaeus, 1758)\\r\\nUrsus maritimus (Phipps, 1774') #  =\u003e Array\n```\n\nGet the genus of the 1st parsed name in the list:\n```python\nresults[0].genus() #  =\u003e String\n'Ursus'\n```\n\n---\n## Deviations\n\nSome extra helpers are included that extend the functionality of GNparser.\n\n1) The page() method gets the page number out of the unparsed tail:\n```python\n\u003e\u003e\u003e result = gnparser('Ursus arctos Linnaeus, 1758: 81')\nresult.page()  # =\u003e String\n'81'\n```\n\n2) The authorship() method returns a formatted authorship string depending on the number of authors. If it is one author with a year, it will return as Smith, 1970. For two authors and a year it will return as Smith \u0026 Johnson, 1970. For three authors it will return as Smith, Johnson \u0026 Jones, 1970. Any additional authors beyond 3 will be comma separated with the last author included with an ampersand.\n```python\n\u003e\u003e\u003e result = gnparser('Aus bus cus Smith, Johnson, \u0026 Jones, 1970')\nresult.authorship()  # =\u003e String\n'Smith, Johnson \u0026 Jones, 1970'\n```\n\n3) The infraspecies() method will return the infraspecies name. Currently there is no special methods for ranks lower than trinomials but you can access them with the infraspecies_details() method. Please [open an issue](https://github.com/gnames/pygnparser/issues/new) if you need it added.\n```python\n\u003e\u003e\u003e result = gnparser('Aus bus cus')\nresult.infraspecies()  # =\u003e String\n'cus'\n```\n\n4) If you wish to abbreviate author strings with over a certain threshold of authors as *et al.* beyond a certain cutoff you can use the parameter `et_al_cutoff=3` on the authorship methods, which would re-format `Smith, Jones \u0026 Anderson, 1999` into `Smith et al., 1999`. By default *et al.* formatting is disabled.\n```python\n\u003e\u003e\u003e result = gnparser('Aus bus cus (Smith, Anderson, Jones, O\\'Brian \u0026 Peters in Richards, Shultz, Anderson \u0026 Smith, 1999) Ryan in Anderson, Smith, \u0026 Jones, 2000')\n\u003e\u003e\u003e result.authorship(et_al_cutoff=3) # =\u003e String\n'(Smith et al. in Richards et al., 1999) Ryan in Anderson et al., 2000'\n\u003e\u003e\u003e res.original_authorship(et_al_cutoff=3) # =\u003e String\n'Smith et al. in Richards et al., 1999'\n\u003e\u003e\u003e res.combination_authorship(et_al_cutoff=3) # =\u003e String\n'Ryan in Anderson et al., 2000'\n```\n\n---\n## Other GNparser Libraries\n\n* Node.js: [node-gnparser](https://github.com/amazingplants/node-gnparser)\n* R: [rgnparser](https://github.com/ropensci/rgnparser)\n* Ruby Gem: [biodiversity](https://github.com/GlobalNamesArchitecture/biodiversity)\n\n---\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/gnames/pygnparser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/gnames/pygnparser/blob/main/CODE_OF_CONDUCT.md).\n\n---\n## Development\n\nAfter checking out the repo, change into the package directory `cd pygnparser`, run `pip install .` to install the package, and `pip install -r requirements.txt` to install the dependencies. Then, run `pytest` to run the tests. You can also run `bin/console` for an interactive Python prompt that will allow you to experiment with the above example commands.\n\n---\n## License\n\nThe package is available as open source under the terms of the [MIT](https://github.com/gnames/pygnparser/blob/main/LICENSE.txt) license. You can learn more about the MIT license on [Wikipedia](https://en.wikipedia.org/wiki/MIT_License) and compare it with other open source licenses at the [Open Source Initiative](https://opensource.org/license/mit/).\n\n---\n## Code of Conduct\n\nEveryone interacting in the pyGNparser project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/gnames/pygnparser/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnames%2Fpygnparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgnames%2Fpygnparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnames%2Fpygnparser/lists"}