MCPcopy Create free account
hub / github.com/ScienciaLAB/document-qa / process

Method process

document_qa/grobid_processors.py:619–654  ·  view source on GitHub ↗

Extract material-mention spans from *text*. Args: text: Plain text to analyse. Returns: list[dict]: Span dicts with ``offset_start``, ``offset_end``, ``type`` (``"material"``), and optional ``formula`` keys.

(self, text)

Source from the content-addressed store, hash-verified

617 self.grobid_superconductors_client = grobid_superconductors_client
618
619 def process(self, text):
620 """Extract material-mention spans from *text*.
621
622 Args:
623 text: Plain text to analyse.
624
625 Returns:
626 list[dict]: Span dicts with ``offset_start``, ``offset_end``,
627 ``type`` (``"material"``), and optional ``formula`` keys.
628 """
629 preprocessed_text = text.strip()
630 status, result = self.grobid_superconductors_client.process_text(preprocessed_text, "processText_disable_linking")
631
632 if status != 200:
633 result = {}
634
635 spans = []
636
637 if "passages" in result:
638 materials = self.parse_superconductors_output(result, preprocessed_text)
639
640 for m in materials:
641 item = {"text": preprocessed_text[m["offset_start"] : m["offset_end"]]}
642
643 item["offset_start"] = m["offset_start"]
644 item["offset_end"] = m["offset_end"]
645
646 if "formula" in m:
647 item["formula"] = m["formula"]
648
649 item["type"] = "material"
650 item["raw_value"] = m["text"]
651
652 spans.append(item)
653
654 return spans
655
656 def parse_materials(self, text):
657 status, result = self.grobid_superconductors_client.process_texts(text.strip(), "parseMaterials")

Callers

nothing calls this directly

Calls 2

process_textMethod · 0.80

Tested by

no test coverage detected