Repository navigation
Detect language in the markdown pipelines and filter on it - #86
Merged
Merged
Conversation
The columnar index carries CLD2 labels Common Crawl computed over the raw HTML. They are unreliable for low resource languages and missing outright on a good share of rows, which makes "give me the Vietnamese pages" harder than it should be. Both markdown pipelines now run a trigram identifier over the Markdown they extracted and write the answer into two new columns, language and language_confidence. Detecting on the extracted text rather than the HTML is the point: that is the text the dataset keeps. --lang keeps only one language and --min-lang-confidence sets the floor, defaulting to 0.8, the identifier's own reliability threshold. Without --lang nothing is dropped and the columns are still filled in, so an unfiltered shard stays filterable later without extracting it again. A document with too little text to identify comes out with an empty language and is dropped by a filter rather than kept, because a filtered export asks for documents known to be in one language and "we could not tell" is not that. The identifier gets a cleaned sample, not the raw Markdown. A link heavy page carries more characters of slug than of prose and a Vietnamese slug has no diacritics by definition, so the link targets have to go while the link text stays. On the vnexpress.net homepage that is the difference between confidence 0.16 and confidence 1. The export schema becomes open-markdown-v3. The two columns are appended and nothing else changes, so a v2 reader that projects the columns it knows reads a v3 file unchanged. The default repo moves to open-index/open-markdown-v3 to keep the schemas in separate repos. --lang with refetch --fetch-only is a usage error, since fetch-only never produces the Markdown the identifier reads. Run stats report the drop rate and the detected mix. They also ride on the journal events as lang_dropped and lang_counts, because the text summary is suppressed in the machine progress modes and the drop rate is the first thing to check when a shard comes out smaller than expected. New: ccrawl content lang <url> answers the same question for one URL and prints the text the identifier judged, which is how you find out why a page was kept or dropped.
7 tasks done
tamnd
added a commit
that referenced
this pull request
Aug 10, 2026
The language identifier has been imported from ccrawl/lang.go since #86, so go.mod listing it as indirect is wrong and go mod tidy keeps saying so. The tidy job on main has been red since that merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #47.
The columnar index carries CLD2 labels Common Crawl computed over the raw HTML. Those labels are unreliable for low resource languages and missing outright on a good share of rows, so "give me the Vietnamese pages" is harder than it should be.
Both markdown pipelines now run a trigram identifier over the Markdown they extracted and write the answer into two new columns,
languageandlanguage_confidence. Detecting on the extracted text rather than on the HTML is the whole point: that is the text the dataset keeps.--langkeeps only one language,--min-lang-confidencesets the floor and defaults to 0.8, which is the identifier's own reliability threshold.ccrawl content lang <url>answers the same question for a single URL and prints the text the identifier judged, which is how you find out why a page was kept or dropped.Decisions worth arguing with
Without
--langnothing is dropped and the columns are still filled in, so an unfiltered shard stays filterable later without extracting it again.A document with too little text to identify comes out with an empty
language, and a filter drops it. A filtered export asks for documents known to be in one language, and "we could not tell" is not that.The identifier gets a cleaned sample rather than the raw Markdown. A link heavy page, which on a news site means the homepage and every section index, carries more characters of slug than of prose, and a Vietnamese slug has no diacritics by definition. Link targets go, link text stays, because the link text is the headline. On the vnexpress.net homepage that is the difference between confidence 0.16 and confidence 1.
--langwithmarkdown refetch --fetch-onlyis a usage error rather than a silently ignored flag, since fetch-only never produces the Markdown the identifier reads. It exits 2.User visible default change
The export schema becomes open-markdown-v3 and the default repo moves from
open-index/open-markdown-v2toopen-index/open-markdown-v3, so the two schemas stay in separate repos. Anyone pinning a repo with--repois unaffected.Done when, checked against a real crawl
Three shards of CC-MAIN-2026-30, 62824 documents converted,
--lang vie --min-lang-confidence 0.8:lang_droppedandlang_countson the journal events, because the text summary is suppressed in the machine progress modes and the drop rate is the first thing to check when a shard comes out smaller than expected.The one miss is worth writing down: a mojibake page, UTF-8 served as Latin-1, whose garbled Cyrillic carries enough accented Latin characters to read as Vietnamese. 42 of the 647 rows show mojibake of some kind, most of them genuinely Vietnamese pages with broken encoding. Romanized Vietnamese written without tone marks is detected as Vietnamese, which is usually what you want.
Docs say plainly that this is a coarse pre-filter and not a substitute for a language specific classifier, in the CLI reference, the markdown reference, and the command help.
Gates
gofmt -l .,go vet ./...,go test ./...,golangci-lint run, andscripts/docs-drift.shall clean.