INNER CODE UNIT · Python

extract_note_content

grobidOrg/grobid · grobid-trainer/scripts/check_note_consistency.py:19

def extract_note_content(xml_file_path):
    """
    Extract note content from a TEI XML file.
    Returns two dictionaries: headnotes and footnotes with content as keys and line numbers as values.
    """
    headnotes = defaultdict(list)
    footnotes = defaultdict(list)

    try:
        with open(xml_file_path, 'r', encoding='utf-8') as f:
            lines = f.readlines()

        for i, line in enumerate(lines, 1):
            # Match note tags with place attributes
            headnote_match = re.search(r'<note\s+place=["\']headnote["\']>(.*?)</note>', line, re.DOTALL)
            footnote_match = re.search(r'<note\s+place=["\']footnote["\']>(.*?)</note>', line, re.DOTALL)

            if headnote_match:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…