from __future__ import annotations import importlib.util from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def _load_module(name: str, relative_path: str): module_path = ROOT / relative_path spec = importlib.util.spec_from_file_location(name, module_path) module = importlib.util.module_from_spec(spec) assert spec.loader is not None spec.loader.exec_module(module) return module def test_thesis_conversion_separates_appendix_titles(tmp_path) -> None: converter = _load_module("convert_thes_to_latex", "tools/convert_thes_to_latex.py") source = ROOT / "THES" / "INT_ANN.TXT" destination = tmp_path / "thesis.tex" converter.convert_thesis_file( source, destination, "Integration and Hybridization in Neural Network Modelling", ) tex = destination.read_text(encoding="utf-8") assert ( r"\chapter{Data File Listing: Classical Sequences Data File}" in tex ) assert ( r"\chapter{Data File Listing: Back-Propagation Network Data File}" in tex ) assert "Classical Sequences Data File Appendix 16" not in tex def test_bibtex_export_preserves_year_suffix_and_extracts_proceedings_fields() -> None: extractor = _load_module("extract_thesis_bibtex", "tools/extract_thesis_bibtex.py") entry = ( "Carpenter, G., and Grossberg, S. 1987a. " "A massively parallel architecture for a self-organizing neural pattern recognition machine. " "Computer Vision, Graphics, and Image Processing 37, 54-115." ) bibtex = extractor.to_bibtex(entry, 1) assert "@article{Carpenter1987a" in bibtex assert "year = {1987a}" in bibtex assert "journal = {Computer Vision, Graphics, and Image Processing}" in bibtex assert "volume = {37}" in bibtex assert "pages = {54-115}" in bibtex def test_bibtex_export_applies_manual_normalization_overrides() -> None: extractor = _load_module("extract_thesis_bibtex", "tools/extract_thesis_bibtex.py") hopfield_entry = ( "Hopfield, J. J. 1982. Neural networks and physical systems with emergent " "collective computational abilities. Proceedings of the National Academy " "of Sciences 79, 2554-2558." ) hopfield_bibtex = extractor.to_bibtex(hopfield_entry, 1) assert "@article{Hopfield1982" in hopfield_bibtex assert "journal = {Proceedings of the National Academy of Sciences}" in hopfield_bibtex assert "volume = {79}" in hopfield_bibtex leven_entry = ( "Leven, S. 1987b. S.A.M.: a triune extension to the ART model. " "'North Texas State University Symposium on Neural Networks' Poster Presentation." ) leven_bibtex = extractor.to_bibtex(leven_entry, 2) assert "@inproceedings{Leven1987b" in leven_bibtex assert "title = {S.A.M.: a triune extension to the ART model}" in leven_bibtex