"""Regression tests for utils/pdf.py section + reference extraction. Root causes fixed here: roman-numeral/plain-numbered headings ("VI. Results and Discussion", "4.1 Methodology") collapsed the whole body into one section, and references numbered "1. Author, Title." (no brackets) were never extracted — which silently killed the citation-relevance agent and starved the corpus-similarity pipeline of text. """ from __future__ import annotations from utils.pdf import extract_references, split_into_sections PAPER = """An AI-Driven Women Safety System ABSTRACT Women safety is a critical concern in modern society. This paper presents an AI-driven women safety system. I. Introduction Women safety has become one of the most pressing social challenges. II. Problem Statement and Motivation Most existing women safety systems rely on manual SOS activation. III. System Architecture The proposed system follows a modular architecture. IV. Methodology The proposed methodology consists of voice-based distress detection. 4.1 Voice-Based Distress Detection Audio input is captured in one-second intervals. V. Implementation and Working The proposed system is implemented as a mobile-based safety solution. VI. Results and Discussion The system demonstrated strong performance in detecting distress situations. VII. Conclusion This paper presented an AI-driven women safety system. VIII. Future Scope Expanding the training dataset can further improve model accuracy. Acknowledgements The authors would like to express their sincere gratitude. REFERENCES 1. National Crime Records Bureau, Crime in India Report, Government of India, 2022. 2. S. Khan et al., "Deep Learning Techniques for Anomaly Detection," Elsevier, 2023. 3. Verma et al., "AI-Based Smart Safety Systems," International Journal of Computer Applications, 2023. """ def test_section_split_handles_roman_numeral_headings(): sections = split_into_sections(PAPER) keys = {k.strip().lower() for k in sections} assert "i. introduction" in keys assert "vi. results and discussion" in keys assert "viii. future scope" in keys assert "references" in keys def test_section_split_keeps_body_out_of_abstract(): sections = split_into_sections(PAPER) abstract = sections["abstract"] intro = next(v for k, v in sections.items() if "introduction" in k) assert "Women safety is a critical concern" in abstract assert "pressing social challenges" in intro assert "pressing social challenges" not in abstract def test_section_split_dotted_number_heading(): sections = split_into_sections(PAPER) meth = next(v for k, v in sections.items() if "methodology" in k) assert "one-second intervals" in meth def test_extract_references_dot_numbering(): refs = extract_references(PAPER.split("REFERENCES", 1)[1]) assert len(refs) == 3 assert "National Crime Records Bureau" in refs[0] assert "Deep Learning Techniques" in refs[1] assert "Computer Applications, 2023." in refs[2] def test_extract_references_bracket_numbering_still_works(): text = "[1] Alice Author, Title One. 2021.\n[2] Bob Author, Title Two. 2022." refs = extract_references(text) assert len(refs) == 2 assert refs[0].startswith("Alice Author") def test_extract_references_parenthesized_numbering(): text = "(1) First Reference Here. 2020.\n(2) Second Reference There. 2021." refs = extract_references(text) assert len(refs) == 2 assert refs[1].startswith("Second Reference") def test_extract_references_empty_and_garbage(): assert extract_references("") == [] assert extract_references("Some plain paragraph without numbers.") == []