diff --git a/mempalace/entity_detector.py b/mempalace/entity_detector.py index d79509c..85b54e8 100644 --- a/mempalace/entity_detector.py +++ b/mempalace/entity_detector.py @@ -215,6 +215,8 @@ PROSE_EXTENSIONS = { ".md", ".rst", ".csv", + ".tex", + ".bib", } READABLE_EXTENSIONS = { diff --git a/mempalace/miner.py b/mempalace/miner.py index befb1fa..51b94e7 100644 --- a/mempalace/miner.py +++ b/mempalace/miner.py @@ -133,6 +133,8 @@ READABLE_EXTENSIONS = { ".csv", ".sql", ".toml", + ".tex", + ".bib", # C# / .NET ".cs", ".csproj", diff --git a/tests/test_entity_detector.py b/tests/test_entity_detector.py index cc74831..77868f5 100644 --- a/tests/test_entity_detector.py +++ b/tests/test_entity_detector.py @@ -531,6 +531,24 @@ def test_scan_for_detection_skips_git_dir(tmp_path): assert not any(".git" in f for f in file_strs) +def test_scan_for_detection_includes_latex_prose(tmp_path): + # .tex and .bib are prose-heavy (author names, abstracts, citations) and + # belong in the preferred PROSE_EXTENSIONS bucket alongside .md / .rst, + # not the code-file fallback. .bib in particular is almost entirely + # author names — high entity density per byte. + (tmp_path / "paper.tex").write_text( + "\\documentclass{article}\\author{Leslie Lamport}\\begin{document}Body.\\end{document}" + ) + (tmp_path / "refs.bib").write_text( + "@article{l86, author={Leslie Lamport}, title={LaTeX}, year={1986}}" + ) + (tmp_path / "code.py").write_text("import os") + files = scan_for_detection(str(tmp_path)) + extensions = {os.path.splitext(str(f))[1] for f in files} + assert ".tex" in extensions + assert ".bib" in extensions + + # ── module-level constants ────────────────────────────────────────────── @@ -543,6 +561,8 @@ def test_stopwords_contains_common_words(): def test_prose_extensions(): assert ".txt" in PROSE_EXTENSIONS assert ".md" in PROSE_EXTENSIONS + assert ".tex" in PROSE_EXTENSIONS + assert ".bib" in PROSE_EXTENSIONS # ── _print_entity_list ───────────────────────────────────────────────── diff --git a/tests/test_miner.py b/tests/test_miner.py index 85c8fc3..6b001a9 100644 --- a/tests/test_miner.py +++ b/tests/test_miner.py @@ -349,6 +349,20 @@ def test_scan_project_includes_kotlin_files(): ] +def test_scan_project_includes_latex_files(): + with tempfile.TemporaryDirectory() as tmpdir: + project_root = Path(tmpdir).resolve() + write_file( + project_root / "main.tex", + "\\documentclass{article}\n\\begin{document}\nHello, world.\n\\end{document}\n" * 20, + ) + write_file( + project_root / "refs.bib", + "@article{lamport1986, author={Leslie Lamport}, title={LaTeX}, year={1986}}\n" * 20, + ) + assert scanned_files(project_root) == ["main.tex", "refs.bib"] + + def test_scan_project_respects_gitignore(): tmpdir = tempfile.mkdtemp() try: