Skip to content

Convert Claude Code or Codex into the most intelligent Deep Research Agent. Collect, search, and synthesize web research into a persistent, searchable wiki that builds on itself. Hosted API + MCP: hyperresearch.ai

Add "purchase this article" to the paywall phrase list (#91)

Marcelo Oliveirac30c110a33de
diff --git a/src/hyperresearch/core/oa.py b/src/hyperresearch/core/oa.py
index 2149c70..c1ac486 100644
--- a/src/hyperresearch/core/oa.py
+++ b/src/hyperresearch/core/oa.py
@@ -69,6 +69,7 @@ _VERSION_RANK = {
_PAYWALL_PHRASES = (
"purchase pdf",
"buy this article",
+ "purchase this article",
"rent this article",
"purchase access",
"subscribe to access",
diff --git a/tests/test_core/test_oa_recovery.py b/tests/test_core/test_oa_recovery.py
index f1ff14d..47058ac 100644
--- a/tests/test_core/test_oa_recovery.py
+++ b/tests/test_core/test_oa_recovery.py
@@ -125,6 +125,28 @@ class TestNeedsRecovery:
settings = ScholarSettings(oa_min_full_text_chars=100)
assert oa.needs_oa_recovery(_result(ABSTRACT), settings) is False
+ @pytest.mark.parametrize("phrase", oa._PAYWALL_PHRASES)
+ def test_every_listed_phrase_triggers(self, phrase):
+ """Each phrase in the list must actually fire on a long page.
+
+ The phrases are matched literally against the lowercased body, so a
+ phrase that never matches is dead weight nobody notices — the length
+ gate quietly covers for it on short pages. Parametrizing over the
+ tuple keeps a new entry honest.
+ """
+ body = FULL_TEXT[:8000] + f" {phrase.title()} to continue."
+ assert oa.needs_oa_recovery(_result(body), ScholarSettings()) is True
+
+ def test_purchase_this_article_triggers(self):
+ """Regression: the list carried "buy this article" and "purchase pdf"
+ but not "purchase this article", a common publisher wording. On a
+ long interstitial — nav chrome over the length threshold, no article
+ text — that paywall read as full text and no OA lookup was attempted,
+ so the note kept the abstract and the report cited it as though read.
+ """
+ body = FULL_TEXT[:8000] + " Purchase this article to read the full text."
+ assert oa.needs_oa_recovery(_result(body), ScholarSettings()) is True
+
class TestResolve:
def test_arxiv_ids_are_declined(self, tmp_vault, monkeypatch):