/**
* Fully parse the supplied name also trying to extract authorships, a conceptual sec reference, remarks or notes
* on the nomenclatural status. In some cases the authorship parsing proves impossible and this nameparser will
* return null.
*
* For strings which are no scientific names and scientific names that cannot be expressed by the ParsedName class
* the parser will throw an UnparsableException with a given NameType and the original, unparsed name. This is the
* case for all virus names and proper hybrid formulas, so make sure you catch and process this exception.
*
* @param scientificName the full scientific name to parse
* @param rank the rank of the name if it is known externally. Helps identifying infrageneric names vs bracket authors
*
* @throws UnparsableNameException
*/
public ParsedName parse(final String scientificName, Rank rank) throws UnparsableNameException {
if (Strings.isNullOrEmpty(scientificName)) {
unparsable(NameType.NO_NAME, null);
}
SciNameLexer lexer = new SciNameLexer(CharStreams.fromString(scientificName));
// Get a list of matched tokens
CommonTokenStream tokens = new CommonTokenStream(lexer);
SciNameParser parser = new SciNameParser(tokens);
// use visitor to transform to ParsedName
ParsedNameVisitor visitor = new ParsedNameVisitor();
return visitor.visit(parser.scientificName());
}
NameParserANTLR.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:name-parser
作者:
评论列表
文章目录