"""Tests for the vocabulary elevation module.""" import pytest from src.vocabulary.awl_loader import AWLLoader from src.vocabulary.lexical_substitution import RegisterFilter def test_awl_loader(tmp_path): """Test that AWL words are loaded correctly.""" awl_file = tmp_path / "test_awl.txt" awl_file.write_text("analysis\nresearch\nmethod\n") loader = AWLLoader(primary_path=str(awl_file), synonyms_path=None) assert len(loader.all_words) == 3 def test_awl_membership(tmp_path): """Test is_academic lookup.""" awl_file = tmp_path / "test_awl.txt" awl_file.write_text("analysis\nresearch\nmethod\n") loader = AWLLoader(primary_path=str(awl_file), synonyms_path=None) assert loader.is_academic("analysis") is True assert loader.is_academic("ANALYSIS") is True # Case insensitive assert loader.is_academic("pizza") is False def test_register_filter_contractions(): """Test that contractions are expanded.""" rf = RegisterFilter() result = rf.apply("I don't think it's correct.") assert "do not" in result assert "it is" in result def test_register_filter_colloquialisms(): """Test that colloquial phrases are replaced.""" rf = RegisterFilter() result = rf.apply("We need to find out a lot of things.") assert "ascertain" in result or "find out" not in result