Address review feedback: deduplicate query_type, clean unused imports, fix defaults

- Remove duplicate detect_query_type from query.py (divergent 5-type version);
  canonical 7-type version lives in query_type.py
- Fix reddit.py import to use query_type.detect_query_type
- Clean unused STOPWORDS/SYNONYMS/tokenize imports from youtube_yt, instagram,
  tiktok, scrapecreators_x, bird_x after relevance consolidation
- Fix _relevance_filter default from 0.7 to 0.0 (items without relevance
  should not silently pass the filter)
- Remove --dateafter from yt-dlp (returns 0 results for evergreen topics)
- Remove restrictSearchableAttributes from HN search (misses Ask/Show HN)
- Lower HN points filter from >5 to >2 (avoids filtering niche posts)
- Add error logging to select_openai_model HTTP failures
- Remove mise.toml and internal planning doc from repo
- Update module docstrings to describe current purpose, not migration history
- Update tests to import from canonical relevance module
This commit is contained in:
Jeffrey Sperling
2026-03-11 18:40:07 -07:00
parent 6c402f66b7
commit 036bcd2ae3
18 changed files with 44 additions and 207 deletions
+7 -6
View File
@@ -8,34 +8,35 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent / "scripts"))
from lib import instagram
from lib.relevance import tokenize as _tokenize
class TestTokenize(unittest.TestCase):
"""Tests for _tokenize()."""
"""Tests for tokenize() from relevance module."""
def test_strips_stopwords(self):
tokens = instagram._tokenize("how to use the AI tools")
tokens = _tokenize("how to use the AI tools")
self.assertNotIn("how", tokens)
self.assertNotIn("the", tokens)
self.assertNotIn("to", tokens)
def test_expands_synonyms(self):
tokens = instagram._tokenize("ai tools")
tokens = _tokenize("ai tools")
self.assertTrue("artificial" in tokens or "intelligence" in tokens)
def test_removes_single_char(self):
tokens = instagram._tokenize("a b c python")
tokens = _tokenize("a b c python")
self.assertNotIn("a", tokens)
self.assertNotIn("b", tokens)
self.assertIn("python", tokens)
def test_lowercases(self):
tokens = instagram._tokenize("Python REACT")
tokens = _tokenize("Python REACT")
self.assertIn("python", tokens)
self.assertIn("react", tokens)
def test_strips_punctuation(self):
tokens = instagram._tokenize("hello, world!")
tokens = _tokenize("hello, world!")
self.assertIn("hello", tokens)
self.assertIn("world", tokens)
+6
View File
@@ -30,6 +30,12 @@ class TestParseVersion(unittest.TestCase):
class TestIsSearchCapableModel(unittest.TestCase):
def test_gpt5_is_capable(self):
"""gpt-5 supports web_search when reasoning is not set to 'minimal'.
Per OpenAI docs, gpt-5 with reasoning effort="minimal" does NOT
support web_search. We never set reasoning params (our usage is
tool invocation + JSON extraction only), so gpt-5 is safe here.
"""
self.assertTrue(models.is_search_capable_model("gpt-5"))
def test_gpt52_is_capable(self):
+1 -22
View File
@@ -6,7 +6,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent / "scripts"))
from lib.query import NOISE_WORDS, detect_query_type, extract_compound_terms, extract_core_subject
from lib.query import NOISE_WORDS, extract_compound_terms, extract_core_subject
class TestExtractCoreSubject(unittest.TestCase):
@@ -126,27 +126,6 @@ class TestNoiseWordsCompleteness(unittest.TestCase):
self.assertIn(w, NOISE_WORDS)
class TestDetectQueryType(unittest.TestCase):
"""Tests for detect_query_type()."""
def test_comparison(self):
self.assertEqual(detect_query_type("React vs Vue"), "comparison")
def test_how_to(self):
self.assertEqual(detect_query_type("how to deploy on Vercel"), "how_to")
def test_opinion(self):
self.assertEqual(detect_query_type("cursor IDE worth it"), "opinion")
def test_product(self):
self.assertEqual(detect_query_type("cursor IDE pricing"), "product")
def test_concept_default(self):
self.assertEqual(detect_query_type("multi-agent reinforcement learning"), "concept")
def test_how_prefix(self):
self.assertEqual(detect_query_type("how does Claude work"), "how_to")
class TestExtractCompoundTerms(unittest.TestCase):
"""Tests for extract_compound_terms()."""
+5 -4
View File
@@ -6,26 +6,27 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent / "scripts"))
from lib import scrapecreators_x
from lib.relevance import tokenize as _tokenize
class TestTokenize(unittest.TestCase):
def test_lowercases(self):
tokens = scrapecreators_x._tokenize("Claude AI")
tokens = _tokenize("Claude AI")
self.assertIn("claude", tokens)
def test_strips_stopwords(self):
tokens = scrapecreators_x._tokenize("the best AI tool")
tokens = _tokenize("the best AI tool")
self.assertNotIn("the", tokens)
self.assertIn("best", tokens) # 'best' is not a stopword in tokenizer
def test_removes_single_char(self):
tokens = scrapecreators_x._tokenize("a b cd ef")
tokens = _tokenize("a b cd ef")
self.assertNotIn("a", tokens)
self.assertNotIn("b", tokens)
self.assertIn("cd", tokens)
def test_expands_synonyms(self):
tokens = scrapecreators_x._tokenize("ai research")
tokens = _tokenize("ai research")
self.assertIn("artificial", tokens)
self.assertIn("intelligence", tokens)
+1 -1
View File
@@ -7,7 +7,7 @@ from pathlib import Path
# Add lib to path
sys.path.insert(0, str(Path(__file__).parent.parent / "scripts"))
from lib.youtube_yt import _compute_relevance, _tokenize
from lib.relevance import token_overlap_relevance as _compute_relevance, tokenize as _tokenize
class TestTokenize(unittest.TestCase):