MCPcopy
hub / github.com/HKUDS/RAG-Anything / get_parser

Function get_parser

raganything/parser.py:2493–2522  ·  view source on GitHub ↗

Get a parser instance by name. Checks built-in parsers first, then falls back to the custom parser registry populated via :func:`register_parser`. Args: parser_type: Parser name (e.g., "mineru", "docling", "paddleocr", or any custom registered name). R

(parser_type: str)

Source from the content-addressed store, hash-verified

2491
2492
2493def get_parser(parser_type: str) -> Parser:
2494 """Get a parser instance by name.
2495
2496 Checks built-in parsers first, then falls back to the custom parser
2497 registry populated via :func:`register_parser`.
2498
2499 Args:
2500 parser_type: Parser name (e.g., "mineru", "docling", "paddleocr",
2501 or any custom registered name).
2502
2503 Returns:
2504 An instance of the requested parser.
2505
2506 Raises:
2507 ValueError: If the parser name is not recognized.
2508 """
2509 parser_name = (parser_type or "mineru").strip().lower()
2510 if parser_name == "mineru":
2511 return MineruParser()
2512 if parser_name == "docling":
2513 return DoclingParser()
2514 if parser_name == "paddleocr":
2515 return PaddleOCRParser()
2516 # Check custom parser registry
2517 if parser_name in _CUSTOM_PARSERS:
2518 return _CUSTOM_PARSERS[parser_name]()
2519 raise ValueError(
2520 f"Unsupported parser type: {parser_type}. "
2521 f"Supported parsers: {', '.join(get_supported_parsers())}"
2522 )
2523
2524
2525def main():

Calls 4

MineruParserClass · 0.85
DoclingParserClass · 0.85
PaddleOCRParserClass · 0.85
get_supported_parsersFunction · 0.85