---
type: "Source File"
title: "\"\"\"Deterministic extraction checks used before content reaches scoring.\"\"\""
description: "\"\"\"Deterministic extraction checks used before content reaches scoring.\"\"\" from __future__ import annotations import re MIN_ARTICLE_CHARS = 350 HARD_INTERSTITIAL_MARKERS = { \"google_consent\": ( \"before you continue to."
resource: "https://www.copecheck.com"
tags: ["copecheck", "main", "source-file", "py"]
timestamp: "2026-08-24T12:39:23Z"
site: "main"
source_path: "copecheck/content_quality.py"
---

# """Deterministic extraction checks used before content reaches scoring."""

Source path: `copecheck/content_quality.py`  
Index snapshot generated: `2026-11-24T13:42:54Z`  
File modified: `2026-08-24T12:39:23Z`

```py
"""Deterministic extraction checks used before content reaches scoring."""
from __future__ import annotations

import re


MIN_ARTICLE_CHARS = 350

HARD_INTERSTITIAL_MARKERS = {
    "google_consent": (
        "before you continue to google",
        "we use cookies and data, including ip addresses",
    ),
    "yahoo_consent": (
        "ihre privatsphäre ist uns wichtig",
        "bei yahoo verwenden wir cookies",
    ),
    "linkedin_consent": (
        "linkedin and 3rd parties use essential and non-essential cookies",
        "select accept to consent or reject to decline non-essential cookies",
    ),
    "javascript_challenge": (
        "please enable javascript and cookies to continue",
        "checking your browser before accessing",
        "press and hold to confirm you are a human",
    ),
    "publisher_consent": (
        "our privacy policy has been updated! the conference board uses cookies",
    ),
    "access_block": (
        "temporarily unavailable due to unusual traffic",
    ),
}

SOFT_CONSENT_MARKERS = (
    "accept all cookies", "reject all cookies", "manage consent",
    "consent preferences", "legitimate interest", "privacy choices",
    "cookie policy", "privacy preference center", "our partners",
    "store and/or access information",
)


def _normalise(text: str) -> str:
    return re.sub(r"\s+", " ", (text or "").lower()).strip()


def extraction_quality_issue(text: str) -> str | None:
    """Return a stable reason code when text is clearly not an article."""
    clean = _normalise(text)
    head = clean[:3000]
    for reason, markers in HARD_INTERSTITIAL_MARKERS.items():
        if any(marker in head for marker in markers):
            return reason
    if len(clean) < 2000 and clean.startswith(("access denied", "request blocked")):
        return "access_block"
    soft_hits = sum(marker in head for marker in SOFT_CONSENT_MARKERS)
    if soft_hits >= 3 and len(clean) < 6000:
        return "consent_interstitial"
    if len(clean) < 1800 and re.match(
        r"^(404\b|page not found\b|the page you requested (?:was not|could not be) found\b)",
        clean,
    ):
        return "not_found_page"
    if len(clean) < MIN_ARTICLE_CHARS:
        return "too_short"
    return None


def is_article_text(text: str) -> bool:
    return extraction_quality_issue(text) is None
```
