MCPcopy Create free account
hub / github.com/HzaCode/OneCite / parse

Method parse

onecite/pipeline/parser.py:23–41  ·  view source on GitHub ↗

Parse input content into a list of raw entries. Args: input_content: The raw text or BibTeX string to parse. input_type: ``"txt"`` for plain-text references or ``"bib"`` for BibTeX format. Returns: A list of :class:`RawEntry` dict

(self, input_content: str, input_type: str)

Source from the content-addressed store, hash-verified

21 self.logger = logging.getLogger(__name__)
22
23 def parse(self, input_content: str, input_type: str) -> List[RawEntry]:
24 """Parse input content into a list of raw entries.
25
26 Args:
27 input_content: The raw text or BibTeX string to parse.
28 input_type: ``"txt"`` for plain-text references or
29 ``"bib"`` for BibTeX format.
30
31 Returns:
32 A list of :class:`RawEntry` dictionaries.
33 """
34 self.logger.info(f"Starting to parse {input_type} format input content")
35
36 if input_type.lower() == 'bib':
37 return self._parse_bibtex(input_content)
38 elif input_type.lower() == 'txt':
39 return self._parse_text(input_content)
40 else:
41 raise ParseError(f"Unsupported input type: {input_type}")
42
43 def _parse_bibtex(self, bibtex_content: str) -> List[RawEntry]:
44 """Parse BibTeX format content"""

Callers 2

processMethod · 0.80
_get_arxiv_metadataMethod · 0.80

Calls 3

_parse_bibtexMethod · 0.95
_parse_textMethod · 0.95
ParseErrorClass · 0.85

Tested by

no test coverage detected