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

Method process

onecite/core.py:145–183  ·  view source on GitHub ↗

Run all four pipeline stages and return results with a report. Args: input_content: The raw text or BibTeX content to process. input_type: Format of *input_content* — ``"txt"`` for plain-text references or ``"bib"`` for BibTeX. template_na

(self, input_content: str, input_type: str, template_name: str,
                output_format: str, interactive_callback: Callable[[List[Dict]], int])

Source from the content-addressed store, hash-verified

143 self.formatter = FormatterModule()
144
145 def process(self, input_content: str, input_type: str, template_name: str,
146 output_format: str, interactive_callback: Callable[[List[Dict]], int]) -> Dict[str, Any]:
147 """Run all four pipeline stages and return results with a report.
148
149 Args:
150 input_content: The raw text or BibTeX content to process.
151 input_type: Format of *input_content* — ``"txt"`` for
152 plain-text references or ``"bib"`` for BibTeX.
153 template_name: Name of the YAML template that controls
154 which fields are collected (e.g.
155 ``"journal_article_full"``).
156 output_format: Output format. Only ``"bibtex"`` is
157 supported; any other value raises ``FormatError``.
158 interactive_callback: A callable that receives a list of
159 candidate dictionaries and returns the index of the
160 selected candidate.
161
162 Returns:
163 A dictionary with two keys:
164
165 * ``results`` — a list of formatted citation strings.
166 * ``report`` — a dict containing ``total``, ``succeeded``,
167 and ``failed_entries``.
168 """
169 self.logger.info("Starting OneCite processing pipeline")
170
171 try:
172 template = self.template_loader.load_template(template_name)
173 raw_entries = self.parser.parse(input_content, input_type)
174 identified_entries = self.identifier.identify(raw_entries, interactive_callback)
175 completed_entries = self.enricher.enrich(identified_entries, template, raw_entries)
176 result = self.formatter.format(completed_entries, output_format)
177
178 self.logger.info("OneCite processing pipeline completed")
179 return result
180
181 except Exception as e:
182 self.logger.error(f"Processing pipeline execution failed: {str(e)}")
183 raise
184
185
186def process_references(

Callers 1

process_referencesFunction · 0.95

Calls 5

load_templateMethod · 0.80
parseMethod · 0.80
identifyMethod · 0.80
enrichMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected