aroche / taxon_parser Goto Github PK
View Code? Open in Web Editor NEWA Python library to parse taxon names into elementary components
License: Apache License 2.0
A Python library to parse taxon names into elementary components
License: Apache License 2.0
First of all, thank you very much for porting this to Python.
Is this finished, or is it a work in progress?
The main page says "Results of the parsing are ParsedName
objects. These have the following attributes and functions: ..."
Among them, you mention nameMinimal()
, but I can't figure out how to make this and other functions work.
This is what I tried based on your example code:
from taxon_parser import TaxonParser, UnparsableNameException
parser = TaxonParser("Abies pectinata mill.")
try:
parsed_name = parser.parse()
print(parsed_name)
# HERE I ADDED THESE:
print(parsed_name.genus) # THIS WORKS
# TRY TO PRINT A SIMPLE NAME:
print(parsed_name.nameMinimal()) # THIS FAILS
except UnparsableNameException as e:
print("this name does not seem to be a valid taxon name: \n" + e )
But I am getting this error:
AttributeError: 'ParsedName' object has no attribute 'nameMinimal'
I am Python newbie. Could you please tell me what is the correct syntax to call these functions?
I tried to follow this suggestion in StackOverflow, and I found some other methods with names different to those mentioned in taxon_parser documentation (like canonicalNameComplete
or canonicalNameMinimal
)... but they also raised errors when I used them instead of nameMinimal
in the above code:
Trying canonicalNameMinimal
I got this error:
Traceback (most recent call last):
File "nomenclature.py", line 10, in parsename
print(parsed_name.canonicalNameMinimal())
File "C:\Python38\lib\site-packages\taxon_parser\name_parser_api\parsedname.py", line 231, in canonicalNameMinimal
return nameformatter.canonicalMinimal(self)
File "C:\Python38\lib\site-packages\taxon_parser\name_parser_api\util\nameformatter.py", line 43, in canonicalMinimal
return buildName(n, False, False, False, False, False, True, True, False, False, False, False, False, False)
File "C:\Python38\lib\site-packages\taxon_parser\name_parser_api\util\nameformatter.py", line 227, in buildName
name = unicodeutils.ascii(name)
File "C:\Python38\lib\site-packages\taxon_parser\name_parser_api\util\unicodeutils.py", line 14, in ascii
return ''.join(c for c in unicodedata.normalize('NFD', s)
NameError: name 's' is not defined
Trying canonicalNameComplete
I got this error:
Traceback (most recent call last):
File "nomenclature.py", line 10, in parsename
print(parsed_name.canonicalNameComplete())
File "C:\Python38\lib\site-packages\taxon_parser\name_parser_api\parsedname.py", line 235, in canonicalNameComplete
return nameformatter.canonicalComplete(self)
File "C:\Python38\lib\site-packages\taxon_parser\name_parser_api\util\nameformatter.py", line 51, in canonicalComplete
return buildName(n, True, True, True, True, True, True, False, True, True, True, True, True, True)
File "C:\Python38\lib\site-packages\taxon_parser\name_parser_api\util\nameformatter.py", line 204, in buildName
if showSensu and n.getTaxonomicNote() is not None:
AttributeError: 'ParsedName' object has no attribute 'getTaxonomicNote'
BTW, documentation shows two different versions of canonicalName()
function (I guess one of them is wrong):
ParsedName.canonicalName(): A full scientific name with authorship from the individual properties in its canonical form. Autonyms are rendered without authorship and subspecies are using the subsp rank marker unless a name is assigned to the zoological code.
ParsedName.canonicalName(): A full scientific name just as canonicalName, but without any authorship.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.