is_w3c_curie
- is_w3c_curie(curie: str) bool [source]
Return if the string is a valid CURIE under the W3C specification.
- Parameters:
curie – A string to check if it is a valid CURIE under the W3C specification.
- Returns:
True if the string is a valid CURIE under the W3C specification.
Warning
This is slightly different from the
curies.Converter.is_curie()
function, which checks if a given CURIE is valid under the extended prefix map contained within the converter.Further, the base converter is slightly more lenient than the W3C specification by default to allow for the inclusion of CURIEs, e.g., for SMILES strings like
smiles:CC(=O)NC([H])(C)C(=O)O
. These are useful, but not technically valid due to their inclusion of brackets.Examples
If no prefix is given, the host language chooses how to assign a default prefix.
>>> is_w3c_curie(":test") True
From the specification, regarding using an underscore as the prefix
The CURIE prefix ‘_’ is reserved for use by languages that support RDF. For this reason, the prefix ‘_’ SHOULD be avoided by authors.
>>> is_w3c_curie("_:test") True
This is invalid because a CURIE prefix isn’t allowed to start with a number. It has to start with either a letter, or an underscore.
>>> is_w3c_curie("4cdn:test") False
Empty strings are explicitly noted as being invalid.
>>> is_w3c_curie("") False