Skip to content

Write each forum post's author and date above its body - #18

Merged
jasir-serpapi merged 10 commits into
mainfrom
forum-post-attribution
Nov 9, 2026
Merged

jasir-serpapi merged 10 commits into
mainfrom
forum-post-attribution

Conversation

@Alaa-abdulridha

@Alaa-abdulridha Alaa-abdulridha commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A blind LLM judge comparing outputs preferred the old code on forum threads: the current code drops every post's author and date, so a reader cannot tell who wrote which reply. The header that holds them (avatar, name, rank, post count, date, permalink) is furniture that boilerplate removal and conditional cleaning drop. Examples (dev): 0547 (Affinity, Invision), 0579 (Cruise Critic, Invision), 0545 (Evernote, Invision), 0523 (XenForo), 0550 (Linus Tech Tips, Invision). The WCXB references keep each post's author and date ("JGD\nApril 2, 2024\n\n...").

Change

New PostAttribution, run on pages whose metadata says :forum or :qa, in two steps:

  • Read (#call, before Boilerplate, so it still sees the member panels that Recover streamed and split content, and drop repeated forum text #16 removes there): a post is the lowest ancestor of a date that has a sibling of the same kind (first class) holding a date too and that names an author. An opening post that stands apart from the replies (Rick Steves' article.topic before section#replies, Vanilla) is the lowest ancestor of an earlier date that names an author and is followed by the replies. Dates come from <time> and itemprop="datePublished"/"dateCreated"; a date wrapped in another date is read from the inner one, and a date labelled as the member's ("Joined", "Member since", "Registered", "Last seen", and a few German, French and Spanish equivalents) is skipped. The author is the nearest author element before the date: itemprop="author" (its itemprop="name"), rel="author", or a class ending in username/author/poster/creator (ipsUsername, bigusername, username-coloured, cAuthorPane_author; not author-badge). Names and dates inside a <blockquote> belong to the quoted post and are skipped. The body is the first sibling after the date, on the way up to the post, that holds content; a sibling named signature or footer (or a <footer>) is never the body: when the climb meets one, the body is the element passed over before it that holds words of its own (a short reply with no body-like class and no <p>).
  • Write (#write, after ContentLocator): the line goes right before the body, and the elements it replaces go: the header line with the date when it holds only a few labels and, after the date, only links and numbers ("Add the WCXB benchmark and a cross-tool comparison #1"); the panel around the name (avatar, rank, post count) when it is short and holds no prose; copies of the same date shown on their own line ("April 2, 20241 yr"). Doing this after content selection keeps the selection exactly as on main (removing headers before scoring changed it on some XenForo pages).
  • Ad slots: a post whose nearest author is exactly an ad label that cannot be a name ("Advertisement", "Advertising", "Sponsored", "Paid content", "Anzeige", "Werbung", "Publicité", "Publicidad", ...) is an ad dressed as a post (Invision, dev 1658) and goes with the headers. "Ad", "Ads" and "Advert" do not count: Ad is a Dutch first name, and a member called Ad keeps every post. The list is the new Patterns::AD_LABEL, which Patterns::BOILERPLATE_TEXT now uses too (plus "ad", "ads", "advert"), so the two stay in sync; BOILERPLATE_TEXT matches exactly what it matched before. A name the Pruner would strip as boilerplate ("Loading", "Share", "Ad") is never used, so no line is ever left without its name; such a post keeps its body and header as on main.

Format: **JGD** · April 2, 2024, one paragraph per post. The bold name reads as a speaker label and cannot be mistaken for the first words of the post; the middle dot is not a word, so it adds no noise; there is no verb ("wrote", "said"), which would add words and collide with quote headers such as "R C-R said:". The date is the one the page shows when it is a full date (with its time when shown, as on Discourse). A relative date ("1 yr", "10 hours ago") or one without a 4-digit year ("07/03/24") gives way to the full date in its title when there is one, otherwise to the machine-readable datetime, written as 2024-04-02.

Threads that sign a post below its body (Stack Exchange answers, some forum themes) are left alone: a line there would read as the next post's. A per-thread vote on whether the date sits above the body decides. Q&A pages keep the attribution where they are threads: Discourse topics declared as QAPage keep authors in their references, while classic Stack Exchange answers, whose references drop authors, are skipped by the rule above.

Speed: Nokolexbor answers Node#matches? by searching the whole document, so body checks now compare the tag name and itemprop, and authors are found in one pass instead of per ancestor. PostAttribution#call on dev 0544 (25 posts): about 24-30 ms -> 12-16 ms, the whole page about 101-124 ms -> 79-96 ms (median of 7 runs, two measurements on a shared machine).

Review round 2 (this push)

  • The ad-slot rule took "Ad", "Ads" and "Advert" for ad labels, so a member named Ad lost the body of every post (a synthetic thread, and dev 1658 with "DenverSteve" renamed to "Ad", which lost "First, there is no best"). The rule now uses only labels that cannot be a name; both cases keep their bodies, and 1658's "Advertisement" slot is still dropped. New spec: "keeps the posts of a member named Ad", which fails on the previous push (a1bc7d3).
  • No WCXB output changed: every output of this push is byte-identical to the previous push's, on its own and merged with Recover streamed and split content, and drop repeated forum text #16.

Review round 1

  • dev 4087 (Rick Steves): the outer <time class="date" title="Reply: ..."> around <time datetime> was picked, so its 9 lines had names only. Now every line has a date (**Barbara** · 2024-07-03), and the opening post, which is article.topic while replies are article.reply, gets its line too.
  • dev 1658 (Invision): the "Advertisement" pseudo-post no longer gets a line (the Pruner had stripped its name and left · 08/26/2025 01:05 AM); the ad slot is dropped.
  • A short reply followed by a signature or footer keeps its line before it; a member panel's "Joined " no longer becomes the post date. Neither occurs on WCXB; both have specs.
  • Against the first push only 3 pages change: dev 4087 0.9931 -> 0.9814 (dates and the opening post's line; its reference keeps no authors or dates), 0559 0.9897 -> 0.9918 (Vanilla's opening post gets **Linc** · March 2025, as in the reference), 1658 0.7447 -> 0.7472 (ad slot dropped). Dev forum 0.77133 -> 0.77127, test forum unchanged (0.82027).

Results

WCXB, F1 main -> branch (every page type):

type dev (1,497) test (511)
overall 0.8679 -> 0.8688 (+0.0009) 0.8918 -> 0.8919 (+0.0001)
article 0.9496 -> 0.9496 0.9503 -> 0.9503
collection 0.7218 -> 0.7218 0.8021 -> 0.8021
documentation 0.9319 -> 0.9319 0.9419 -> 0.9419
forum 0.7600 -> 0.7713 (+0.0113) 0.8191 -> 0.8203 (+0.0012)
listing 0.7280 -> 0.7280 0.7578 -> 0.7578
product 0.6789 -> 0.6789 0.8253 -> 0.8253
service 0.8381 -> 0.8381 0.8381 -> 0.8381
  • Dev forum: F1 0.75996 -> 0.77127, precision 0.7212 -> 0.7345, recall 0.8802 -> 0.8887; snippets found 0.791 -> 0.792, noise snippets 0.105 -> 0.078; tokens per page 2402 -> 2277. Dev overall tokens 3073 -> 3064, noise snippets 0.066 -> 0.064.
  • Test forum: F1 0.81911 -> 0.82027, precision 0.8083 -> 0.8097, recall 0.8895 -> 0.8900; tokens per page 2821 -> 2813; snippet rates unchanged (0.787 / 0.105).
  • Pages moved by 0.05 or more: dev 6 better, 0 worse; test none.
  • The five examples all show a line per post: 0547 0.432 -> 0.432 (25 posts; the reference covers 3), 0579 0.675 -> 0.671, 0545 0.924 -> 0.938, 0523 0.629 -> 0.629, 0550 0.505 -> 0.523. On 0550 no post body is missing any more: the short reply "I'm leaning towards ... AIO water coolers" that main dropped is back. Also on 0550, conditional cleaning now drops the quoted PCPartPicker list inside one reply, a repeat of the list shown in full earlier in the thread.
  • Scrapinghub 0.9451 -> 0.9451, Mozilla 0.9414 -> 0.9414. Neither corpus has a forum or Q&A page, so PostAttribution never runs there.

Regressions

11 pages lose more than 0.0005 F1, 40 gain. The losses:

  • dev 2797 -0.021, 4087 -0.017, 1658 -0.013, 1350 -0.007, test 5105 -0.006: references without authors. WCXB's dev block 0501-0579 keeps them; the other dev forum pages and all test forum pages do not, so the line costs precision there. On test this is more than paid back by the headers and member panels the line replaces (5032 +0.013, 5028 +0.009, 5092 +0.044).
  • dev 0564 -0.008, 4310 -0.005: Stack Exchange comment cards ("follow-ups"), where an avatar becomes a name and date the reference does not keep.
  • dev 0579 -0.004, 0523 -0.0006: the reference covers fewer posts than the page (precision), recall goes up (0579 0.981 -> 0.993, 0523 0.977 -> 0.996).
  • dev 0502 -0.003, 0512 -0.003: Discourse post numbers go with the header; they matched list numbers in the reference by chance. 0502's reference also keeps "(Full Name)" after the user name, which the line leaves out.

Not covered (no line):

  • Dates that are not in <time> or itemprop: vBulletin 3 (bare text), vBulletin 4 (span.date), MyBB (span.post_date), SMF, NodeBB (span.timeago).
  • Dates only in <meta itemprop> (the preprocessor removes meta).
  • A XenForo theme that shows the date before the name (0516).
  • The opening post of VerticalScope's California theme (dev 0528, 0529, 0530, 0534, 4317; test 5028, 5092, 5144, 5153): its author has itemprop="" and only a BEM class (MessageCard__user-info__name), and its first date is the thread's "last post" date, so it is not recognized as a post.

Known limits from review, none seen on WCXB:

  • A body whose class has "signature" or "footer" as a word ("post-text has-signature") is taken for the closing sibling; with no short reply before it, the post gets no line (main's output).
  • A member panel whose last text is a rank such as "Registered", directly followed by a wrapper that holds only the post date, makes that date look like a join date; the thread gets no lines (main's output).
  • A XenForo-style thread header (p-body-header before p-body-main) with 25 or more characters of tags after the start date gets a line, repeating the first post's.

With #16

How it was tested

  • bundle exec rspec: 244 examples, 0 failures. 16 specs in spec/nokodown/post_attribution_spec.rb on hand-written threads: the line before each body, header and author panel dropped, a full date over a relative one and the ISO fallback, the copy of the date above the body, a header that is an <aside>, a quoted author, a one-word reply, answers signed below their body, an article byline left alone, and from the reviews: an opening post outside the list of replies, a short reply followed by a signature, a member panel's join date, a date wrapped in another date, an ad slot, a member named Ad, and a name the cleanup would remove. The member-named-Ad spec fails on the previous push (a1bc7d3).
  • BOILERPLATE_TEXT checked against its previous form on the ad labels and near misses ("Ad", "Ads", "Advert", "Adam", "adverts", "Advertisement:", "Sponsoredcontent", ...): same result for every one.
  • dev 1658 run locally with "DenverSteve" renamed to "Ad": keeps "First, there is no best"; the original page still drops the ad slot and has no nameless line.
  • tmp/bench/eval.sh . forum-post-attribution-final against main; its outputs compared with the previous push's run (forum-post-attribution-v2), and eval.sh . forum-post-attribution-final-with-16 pr16 for the merge with Recover streamed and split content, and drop repeated forum text #16, compared with forum-post-attribution-v2-with-16.
  • benchmark/quality.rb on Scrapinghub and Mozilla (F1 read with 4 decimals; the script prints 3: 0.945 and 0.941).
  • Read the outputs of the five example pages, of 4087, 1658 and 0559, and of the largest movers.

🤖 Generated with Claude Code

Alaa-abdulridha and others added 3 commits October 28, 2026 12:34
Forum threads lost every post's author and date, because the header they
sit in is furniture that boilerplate removal drops. Read them before that
step and, once the content is selected, write them as one line above each
post's body ("**JGD** · April 2, 2024") in place of the header, the panel
around the name and repeated copies of the date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read a date wrapped in another from the inner one, and skip member
panel dates ("Joined <time>"). Drop ad slots posted by "Advertisement"
and write no line for a name the Pruner would strip. Take a short
reply, not the signature or footer after it, as the body. Attribute an
opening post that stands apart from the replies. Check body parts by
tag name: Node#matches? searches the whole document.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A member named Ad lost the body of every post: the ad-slot rule took
"Ad", "Ads" and "Advert" for ad labels. Ad slots are now told by the
labels that are never names, which the boilerplate pattern shares.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jasir-serpapi and others added 7 commits November 9, 2026 16:28
lib/nokodown.rb conflicted only on the requires: both member_panel (#16)
and post_attribution are loaded.

Co-authored-by: Codex + Claude Opus 5.5 <codex@openai.com>
On XenForo themes that print the name in the member panel and again in
the post header (dev 0523), PostAttribution read the name from the
header, and #16's MemberPanel reduced the panel beside it to a second
"**name**" line: every post opened with two lines, 20 pairs on 0523.

The member panels inside an attributed post, outside its body, are now
part of what the line replaces. Boilerplate still reduces them, so the
selection does not change, and the line they leave goes with the
headers when the content is selected.

WCXB: only dev 0523 changes, 0.627 -> 0.632; no page has a pair left
but dev 2797, where the post under the first line was pruned (as on
main).

Co-authored-by: Codex + Claude Opus 5.5 <codex@openai.com>
The cleanup of date copies took the outermost element around any copy
of the post's date that held nothing else, anywhere in the post. Inside
the body that is content: a reply that is only a date lost its body and
so its name, a date paragraph after the text went, and so did a date in
a quote ("Booked for <date>" became "Booked for").

A copy now goes only when it sits before the body, or first in it with
more of the post after it, the "April 2, 2024 1 yr" line Invision
repeats above each post. Copies in a quote stay, and the climb stops at
the body rather than taking it.

WCXB: no page changes. The 52 copies removed on WCXB (dev 0544, 0546,
0547) all open their post's body and still go.

Co-authored-by: Codex + Claude Opus 5.5 <codex@openai.com>
A theme that puts the post's subject in the header beside the name
("## The north bridge is closed; use the east entrance") lost it: the
author panel and the header line the attribution replaces were removed
whole, heading included, or kept whole with the name and date the line
already says.

A heading in an attributed post that holds neither the name nor the
date, outside the body, quotes and member panels, is the post's
subject. It no longer counts against the header or panel being short
enough to replace, and it is moved out before they are removed. A
heading that repeats the page's h1 is the thread's title, as vBulletin
5 prints above the opening post (test 5032, 5105), and goes with the
header as before.

WCXB: no page changes. Of the 338 headings in replaced headers and
panels on WCXB, all but those two are names (XenForo h4, Invision h3)
or member ranks inside a member panel (XenForo h5).

Co-authored-by: Codex + Claude Opus 5.5 <codex@openai.com>
A post dated only "Yesterday at 10:40", with no year, title or datetime
to read a full date from, got a line with its name alone, and the
header that showed the date went with it.

When there is no full date, the line now shows the date as the page
does, if it is short enough to be one.

WCXB: no page changes; every attributed post there has a full date in
its text, title or datetime.

Co-authored-by: Codex + Claude Opus 5.5 <codex@openai.com>
To find a date's post, every ancestor of every date scanned all its
siblings for another of its kind that holds a date: in a thread of n
posts, each of the n dates scans the n posts, and more where each post
has a class of its own and the climb goes on to the next parent. A
thread of 6,400 posts took 36-41 s on Ruby 2.7 and 3.4 where main takes
3 s for the whole page.

The kinds of a parent's dated children are now counted once per parent
and looked up from then on.

PostAttribution#call, posts with a class of their own (post-N post):
1,600 posts 2.0-2.1 s -> 61-66 ms, 6,400 posts 36 s -> 305-325 ms
(Ruby 2.7 and 3.4). Whole page, 6,400 posts: 41.2 s -> 3.3 s on Ruby
2.7, main 3.0 s. Posts sharing one class: 6,400 posts 6.0 s -> 5.3 s,
main 2.9 s; the rest is the Pruner on 6,400 more paragraphs.

WCXB: no page changes.

Co-authored-by: Codex + Claude Opus 5.5 <codex@openai.com>
CLOSING, the class of the sibling that ends a post, matched any
"signature" or "footer" word, so a body named for having one
("post-text has-signature") was taken for the signature itself. With no
short reply before it the post got no line, and its header stayed as on
main.

A "has-" or "with-" modifier no longer counts, as in
Patterns::SIGNATURE.

WCXB: no page changes.

Co-authored-by: Codex + Claude Opus 5.5 <codex@openai.com>
@jasir-serpapi
jasir-serpapi merged commit c72ee2e into main Nov 9, 2026
4 checks passed
@jasir-serpapi
jasir-serpapi deleted the forum-post-attribution branch November 9, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants