MCPcopy
hub / github.com/HKUDS/LightRAG / normalize_parser_engine

Function normalize_parser_engine

lightrag/parser/routing.py:74–86  ·  view source on GitHub ↗

Normalize engine hints such as mineru-iet to mineru. Also strips an engine-level parameter block, so a stored/encoded ``parse_engine`` like ``mineru(page_range=1-3)`` resolves to the bare engine ``mineru`` (the single chokepoint that keeps parser selection and engine comparisons wor

(engine: Any)

Source from the content-addressed store, hash-verified

72
73
74def normalize_parser_engine(engine: Any) -> str:
75 """Normalize engine hints such as mineru-iet to mineru.
76
77 Also strips an engine-level parameter block, so a stored/encoded
78 ``parse_engine`` like ``mineru(page_range=1-3)`` resolves to the bare
79 engine ``mineru`` (the single chokepoint that keeps parser selection and
80 engine comparisons working once params are encoded into ``parse_engine``).
81 """
82 text = str(engine or "").strip()
83 paren = text.find("(")
84 if paren != -1:
85 text = text[:paren]
86 return text.split("-", 1)[0].strip().lower()
87
88
89def encode_parse_engine(engine: str, engine_params: Mapping[str, Any] | None) -> str:

Calls 1

findMethod · 0.45