I audited my site to measure how similar the article structures were.
The first measurement was 92%, which I used in my conclusions. I later found that the extraction code had included the theme template as article structure. After correcting the boundary, the figure was 12%.
The figures differed by nearly eight times because of one line of extraction code. This article records the method, the boundary error, and the additional statistics that the corrected result still needed.
Why measure shape rather than length
I first checked length: the median body had around three thousand characters, and the shortest had over fifteen hundred. Length did not explain the content-quality concern.
Articles with the same shape can feel templated even when the wording is original. Similar section order, table placement, and endings create that impression. Defining these as detectable structural features makes them measurable.
The original nine binary features were code, table, list, h3, blockquote, image, numbered section, “step” and FAQ. The sample regex counts inline code too, and detects FAQ by text. Freeze these operational definitions when reproducing the measurement.
Where the first measurement went wrong
Profiling the repository source files initially showed that no article had a “related reading” block.
A plugin adds those blocks at render time, along with the reading-progress bar, difficulty badge, and generated table of contents. The source contains the authored body; readers and crawlers also see the surrounding blocks.
So I switched to fetching the rendered HTML. That part was right. The next step was not: I used the <article> element to delimit “the article”.
That produced figure at 100% — every post has an image. The number looked entirely reasonable at the time; technical posts have diagrams. So I accepted it, folded it into the “shares the same skeleton” test, and arrived at 92%.
Then I added three new articles with no images in the body at all, re-measured, and figure was still 100%.
Which finally prompted me to look at what that <img> actually was:
<img alt='' src='.../personal-site-community/avatars/user-1/default-v3.png'>
The author avatar. The theme renders an author box at the foot of every post, and the avatar sits inside <article>. I had been counting it as article content the whole time.
The correction
The right boundary is not <article> but the container holding only the author’s own markup. On this site it carries a data-article-primary attribute; on another theme it will be called something else, but the principle holds: find the line where template injection stops and authored content begins.
For the original 56-article cohort, the record reports approximate largest-combination shares of 92% and 12%, and image rates of 100% and 36% after boundary correction. These historical summaries are retained; the current site corpus has changed.
These differences came from the WordPress theme wrapper. Measuring the authored body requires excluding that shared template.
What the script looks like
The whole measurement is under eighty lines and comes down to three functions. Fetching has to deal with a practical problem: the link is unreliable and returned HTML is frequently truncated, while a truncated response looks exactly like a healthy one.
The original fetch snippet is retained below. Finding </html> is only a completeness screen. Also check curl status, HTTP status, final URL, the expected body container and parsing results to reject complete error pages.
def fetch(slug, tries=4):
for _ in range(tries):
r = subprocess.run(["curl", "-s", "--max-time", "100",
f"{BASE}/{slug}/?nc={random.randint(1, 10**9)}"],
capture_output=True, text=True)
if "</html>" in r.stdout: # only accept complete responses
return r.stdout
return None
Whether a random query changes cache behaviour depends on CDN cache-key rules. Verify the body, cache headers and intended version, and purge using known rules when needed.
Feature extraction is a handful of regexes, each returning a boolean:
def skeleton(h):
f = set()
if '<table' in h: f.add('table')
if re.search(r'<pre|<code', h): f.add('code')
if re.search(r'<(ul|ol)', h): f.add('list')
if re.search(r'<blockquote', h): f.add('quote')
if re.search(r'常见问题|FAQ', h): f.add('faq')
...
return sorted(f)
A consistent rule aids comparison, but systematic error does not automatically cancel. Adding the same image to every page changes feature rates and may merge otherwise distinct combinations. Validate each feature with known structures.
Finding the body boundary
The extraction boundary needs inspection before statistics: choose an article, print the returned fragment, and read it from beginning to end.
What you are checking for is concrete: any navigation links, any author box, any related-posts list, any footer. If any of those appear, the boundary is wrong.
The retained string-cutting snippet can stop at an authored word containing related or mishandle nested markup. Use an HTML parser to select the body container and exclude template nodes by DOM boundary, then inspect examples.
ends = [x.start() for x in [
re.search(r'related|site-experience__next', b),
re.search(r'<footer', b),
re.search(r'</article>', b),
] if x]
body = b[:min(ends)] if ends else b
Initially I cut only at the related block. The consequence: articles that switch related off have no such marker, so the body ran on into the page footer and their length came back six times too large. One article went from 22234 characters to 3407 once corrected.
Both optional markers and multiple string markers can fail. Prefer a defined DOM container, fail on a missing container and test pages with and without template components.
The second number is not the end either
A 12% largest-single-skeleton share still needs other statistics for interpretation:
Code blocks appear in 96% of articles, lists in 95%, tables in 91%. All three together appear in 88%.
The record reports 29 combinations and entropy 4.44 bits. Uniform use of those 29 observed categories has ceiling log2(29)≈4.858 bits. The original 5.81 approximates log2(56), the sample ceiling if all 56 articles differ. Nine binary features have a theoretical ceiling of 9 bits. These are different denominators.
“Largest single combination” is blind to this, because it treats code+list+table and code+list+table+quote as two different skeletons. Taxonomically correct; as a reading experience they are the same thing.
At least three statistics are needed: the share of the largest combination, the occurrence rate of each frequent element, and their co-occurrence rate. The third shows how often the main structure repeats.
Doing this on your own site
The procedure has three steps.
Fetch rendered HTML to study the page readers see. Validated source or extracted body is suitable for authored-content structure. Report those objects separately to avoid mixing in the template again.
Second, separate authored content from theme chrome. Pick one article, print the fragment your extractor returns, and read it — confirm there is no navigation, no author box, no related-posts list in there. I skipped this step, and it cost me a conclusion that was off by a factor of eight.
Report combinations, individual rates and co-occurrence together. High co-occurrence means elements often appear together; it does not establish a fixed section order or duplicated wording.
The output also identifies articles whose structures differ from the majority. Reading those articles helps determine which structures suit their content.
The third error: tokenisation missed local Chinese reuse
After this analysis, I found a long-standing error in the cross-article duplicate detector. Its cause differed from the first two.
Alongside structural uniformity I run cross-article duplicate detection: cut each article into sliding 5-token windows and compute pairwise Jaccard similarity. It consistently reported a site-wide maximum of 0.059, which looked healthy.
In a four-article check, two English pages had the same Chinese nearest neighbour. That calls for checks of tokenisation and shared code. Cross-language pages can share code, terms and citations, so this is not mathematically impossible.
Python’s default Unicode \w+ groups consecutive Han characters and also matches Latin letters, digits and underscores. It can serve as a simple English token rule; Chinese needs an explicitly chosen character or word-token definition.
t = "更糟的是它会冻结同一个循环上所有正在流式输出的对话"
re.findall(r'\w+', t)
# -> one token, 25 characters long
A five-token window can therefore span several Han runs, reducing sensitivity to local reuse. A fully duplicated text with enough tokens can still score highly; short text can produce an empty set. The example has 25 Han characters, grouped into one token by the default regex.
The snippet below makes character five-grams within basic Han runs and word five-grams from Latin letters, digits and underscores. It excludes CJK extension blocks; punctuation breaks Han runs, while extracted Latin words can bridge intervening Han text. Test mixed scripts, short text and empty sets before interpreting results.
def shingles(t, n=5):
out = set()
for run in re.findall(r'[一-鿿]+', t): # Chinese: by character
for i in range(len(run) - n + 1):
out.add(run[i:i+n])
lat = re.findall(r'[A-Za-z0-9_]+', t.lower()) # Latin: by word
for i in range(len(lat) - n + 1):
out.add(tuple(lat[i:i+n]))
return out
The historical maximum was 0.0488 after changing tokenisation, versus 0.059 under the previous rule. Those use different feature sets and are not an improvement measured on one unchanged scale. A maximum alone also cannot establish semantic originality.
This describes literal shingle overlap in the historical cohort. Paraphrases, translated duplication and local reuse need additional checks.
Supporting evidence: I did once write a duplicate article, and I noticed only because its cover image filename collided with an existing one — while this metric reported it as fine. A duplicate check that a filename collision catches and it does not deserved suspicion from the start.
What the three errors have in common
The causes differed, but all three measurements returned plausible numbers without raising an error.
- Measuring source files gave “0% contain related reading” — a precise, wrong number.
- Measuring the whole
<article>gave 92% — a precise number that counted the theme’s own shell. - Splitting Chinese with
\w+gave 0.059 — a precise number reflecting only English.
A script that runs and returns a plausible value still needs validation. Here, unexpected control results exposed the errors: adding three image-free articles left the metric unchanged; the figure rate was exactly 100%; and an English article’s closest match was Chinese.
Test exact duplicates, known partial reuse, unrelated same-language text, mixed scripts, short inputs and template contamination. Nonempty identical sets should have Jaccard 1; unrelated texts may still share terms. Endpoint controls also need checks of intermediate overlap and body extraction.
On measuring yourself
The investigation also showed how long a measurement error could remain without producing an exception.
92% matched my intuition and seemed to explain the observations. I used it in the conclusions before checking the extracted content.
Later, an accidental control exposed the error: adding three articles without images left the metric unchanged. Articles with diagrams would not have exposed it through that comparison.
When measuring your own work, construct a sample with a known answer and check whether the metric changes as expected. If it does not, inspect the extraction boundary and calculation again.
Related: tool pages get 6.4x the clicks of articles at the same rank — another measurement that used this site as its own dataset, and that also computes the probability before calling anything an anomaly.