Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/removals/scoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const navigationIndicators = [
'popular',
'privacy',
'recommended',
'register',
'related',
'responses',
'share',
Expand All @@ -69,6 +68,22 @@ const datePattern = /(?:(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]
// Author attribution pattern — case-sensitive "By" + capitalized name
const bylinePattern = /\bBy\s+[A-Z]/;

// Bare "register" is also a CPU or quantum register. Count it only as a signup
// prompt that opens a block, or as the label of a link or button.
const registrationPromptPattern = /^\s*(?:please\s+)?register\s+(?:now|today|here|to\s+continue|for\s+(?:free|an?\s+account)|(?:an?|your)\s+account)\b/;
const registrationControlPattern = /^(?:please\s+)?register(?:$|\s+(?:for|to)\b)/;

function isRegistrationPrompt(element: Element): boolean {
const text = (element.textContent || '').trim().toLowerCase();
if (!text.includes('register')) return false;
if (registrationPromptPattern.test(text)) return true;
return Array.from(element.querySelectorAll('a[href], button, [role="button"]')).some(control => {
const label = (control.textContent || '').trim().toLowerCase();
return (registrationControlPattern.test(label) || registrationPromptPattern.test(label)) &&
!control.querySelector('code');
});
}

// Pre-compiled navigation indicator regexes for scoreNonContentBlock
const navigationIndicatorRegexes = navigationIndicators.map(
indicator => new RegExp(`\\b${indicator.replace(/\s+/g, '\\s+')}\\b`)
Expand Down Expand Up @@ -355,6 +370,7 @@ export class ContentScorer {
if (headingText && headingText === text.trim()) {
const headingLower = headingText.toLowerCase();
if (!navigationHeadingPattern.test(headingLower) &&
!isRegistrationPrompt(headingChild) &&
!tocHeadingPattern.test(headingLower)) {
return true;
}
Expand All @@ -369,7 +385,7 @@ export class ContentScorer {
let hasNavigationHeading = false;
for (let i = 0; i < headings.length; i++) {
const headingText = (headings[i].textContent || '').toLowerCase().trim();
if (navigationHeadingPattern.test(headingText)) {
if (navigationHeadingPattern.test(headingText) || isRegistrationPrompt(headings[i])) {
hasNavigationHeading = true;
break;
}
Expand Down Expand Up @@ -479,6 +495,9 @@ export class ContentScorer {
indicatorMatches++;
}
}
if (isRegistrationPrompt(element)) {
indicatorMatches++;
}
score -= indicatorMatches * 10;

// Check for high link density (navigation)
Expand Down
40 changes: 40 additions & 0 deletions tests/expected/scoring--algorithm-register.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
```json
{
"title": "Register operations",
"author": "",
"site": "example.com",
"published": ""
}
```

This procedure describes how a receiver processes an encoded state after transmission. The sender prepares a collection of physical systems and applies an encoding operation before delivering the result. The receiver uses a decoding operation to recover the original information. Each operation acts on a specified group of systems rather than on the entire collection. The names attached to these groups distinguish the input from the output and make the instructions precise. Intermediate states may contain errors introduced during transmission. The decoding procedure identifies those errors and corrects them without changing the information that the sender intended to convey. The ordering of the operations is therefore important.

The steps below describe the final part of that procedure. Read each instruction in order and keep the named systems separate throughout the calculation. An operation written beside a system name applies only to that system. A dagger denotes the inverse operation in this example. After the inverse operations have been applied the receiver can produce the decoded state. The final instruction identifies which system contains that state. These conventions also allow the same procedure to be described in ordinary prose without equations. Both descriptions specify the same sequence of operations and the same final result.

## Algorithm

1. Decode the received state.
1. Apply $D$ and output register $A$.
2. Apply $U^\dagger P^\dagger$ to the received register $B$.

### Quantum register operations

Initialize the register before decoding.

Use the `register` keyword.

See the [`register`](https://example.com/reference/register) keyword.

Check `register_state` before returning.

Registered values remain unchanged.

Use the cash register carefully.

The register now contains output.

Call `register` to continue.

We register an account in this example.

Inspect register [state](https://example.com/state) before returning.
16 changes: 16 additions & 0 deletions tests/expected/scoring--registration-heading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```json
{
"title": "Decoding experiment",
"author": "",
"site": "example.com",
"published": ""
}
```

This procedure describes how a receiver processes an encoded state after transmission. The sender prepares a collection of physical systems and applies an encoding operation before delivering the result. The receiver uses a decoding operation to recover the original information. Each operation acts on a specified group of systems rather than on the entire collection. The names attached to these groups distinguish the input from the output and make the instructions precise. Intermediate states may contain errors introduced during transmission. The decoding procedure identifies those errors and corrects them without changing the information that the sender intended to convey. The ordering of the operations is therefore important.

The steps below describe the final part of that procedure. Read each instruction in order and keep the named systems separate throughout the calculation. An operation written beside a system name applies only to that system. A dagger denotes the inverse operation in this example. After the inverse operations have been applied the receiver can produce the decoded state. The final instruction identifies which system contains that state. These conventions also allow the same procedure to be described in ordinary prose without equations. Both descriptions specify the same sequence of operations and the same final result.

The experiment compares the recovered information with the original input under several controlled conditions. Each trial uses the same preparation procedure so that differences in the observed result can be attributed to transmission errors rather than to changes in the initial state. Measurements are collected after decoding and evaluated using the same criteria throughout the experiment. The comparison also checks whether the order of the recovery operations affects the outcome. Repeating the trials with different error patterns establishes which aspects of the procedure remain stable. The interpretation of these measurements depends on keeping the preparation and recovery stages distinct and recording the final state consistently.

This is the last substantive conclusion of our experiment, and it explains the results to our readers.
40 changes: 40 additions & 0 deletions tests/fixtures/scoring--algorithm-register.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- {"url":"https://example.com/algorithm"} -->
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Register operations</title></head>
<body>
<article>
<h1>Register operations</h1>
<p>This procedure describes how a receiver processes an encoded state after transmission. The sender prepares a collection of physical systems and applies an encoding operation before delivering the result. The receiver uses a decoding operation to recover the original information. Each operation acts on a specified group of systems rather than on the entire collection. The names attached to these groups distinguish the input from the output and make the instructions precise. Intermediate states may contain errors introduced during transmission. The decoding procedure identifies those errors and corrects them without changing the information that the sender intended to convey. The ordering of the operations is therefore important.</p>
<p>The steps below describe the final part of that procedure. Read each instruction in order and keep the named systems separate throughout the calculation. An operation written beside a system name applies only to that system. A dagger denotes the inverse operation in this example. After the inverse operations have been applied the receiver can produce the decoded state. The final instruction identifies which system contains that state. These conventions also allow the same procedure to be described in ordinary prose without equations. Both descriptions specify the same sequence of operations and the same final result.</p>
<h2>Algorithm</h2>
<ol>
<li>Decode the received state.
<ol>
<li><div><p>Apply <math><semantics><mi>D</mi><annotation encoding="application/x-tex">D</annotation></semantics></math> and output register <math><semantics><mi>A</mi><annotation encoding="application/x-tex">A</annotation></semantics></math>.</p></div></li>
<li><div><p>Apply <math><semantics><mrow><msup><mi>U</mi><mo>†</mo></msup><msup><mi>P</mi><mo>†</mo></msup></mrow><annotation encoding="application/x-tex">U^\dagger P^\dagger</annotation></semantics></math> to the received register <math><semantics><mi>B</mi><annotation encoding="application/x-tex">B</annotation></semantics></math>.</p></div></li>
</ol>
</li>
</ol>
<div><h3>Quantum register operations</h3></div>
<div><p>Initialize the register before decoding.</p></div>
<div><p>Use the <code>register</code> keyword.</p></div>
<div><p>See the <a href="/reference/register"><code>register</code></a> keyword.</p></div>
<div><p>Check <code>register_state</code> before returning.</p></div>
<div><p>Registered values remain unchanged.</p></div>
<div><p>Use the cash register carefully.</p></div>
<div><p>The register now contains output.</p></div>
<div><p>Call <code>register</code> to continue.</p></div>
<div><p>We register an account in this example.</p></div>
<div><p>Inspect register <a href="/state">state</a> before returning.</p></div>
<div><p>Account access <a href="/register">Register</a></p></div>
<div><p>Register now for free access.</p></div>
<div><p>Register an account to proceed.</p></div>
<div><p>Please register to continue.</p></div>
<div><p>Account access <a href="/register">Register now</a></p></div>
<div><p>Sign up for updates.</p></div>
<div><p>Register now for <math><mi>X</mi></math> access.</p></div>
<nav><p>Account access <a href="/register">Register</a> <math><mi>Y</mi></math></p></nav>
</article>
</body>
</html>
12 changes: 12 additions & 0 deletions tests/fixtures/scoring--registration-heading.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- {"url":"https://example.com/experiment"} -->
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Decoding experiment</title></head>
<body><article>
<p>This procedure describes how a receiver processes an encoded state after transmission. The sender prepares a collection of physical systems and applies an encoding operation before delivering the result. The receiver uses a decoding operation to recover the original information. Each operation acts on a specified group of systems rather than on the entire collection. The names attached to these groups distinguish the input from the output and make the instructions precise. Intermediate states may contain errors introduced during transmission. The decoding procedure identifies those errors and corrects them without changing the information that the sender intended to convey. The ordering of the operations is therefore important.</p>
<p>The steps below describe the final part of that procedure. Read each instruction in order and keep the named systems separate throughout the calculation. An operation written beside a system name applies only to that system. A dagger denotes the inverse operation in this example. After the inverse operations have been applied the receiver can produce the decoded state. The final instruction identifies which system contains that state. These conventions also allow the same procedure to be described in ordinary prose without equations. Both descriptions specify the same sequence of operations and the same final result.</p>
<p>The experiment compares the recovered information with the original input under several controlled conditions. Each trial uses the same preparation procedure so that differences in the observed result can be attributed to transmission errors rather than to changes in the initial state. Measurements are collected after decoding and evaluated using the same criteria throughout the experiment. The comparison also checks whether the order of the recovery operations affects the outcome. Repeating the trials with different error patterns establishes which aspects of the procedure remain stable. The interpretation of these measurements depends on keeping the preparation and recovery stages distinct and recording the final state consistently.</p>
<div><h3><a href="/register">Register for updates</a></h3></div>
<p>This is the last substantive conclusion of our experiment, and it explains the results to our readers.</p>
</article></body>
</html>
Loading