Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →You can detect possible cognitive-distortion language in text with a small Python program that matches regular expressions to phrases such as “always,” “should,” and “they think.” The tutorial’s detector checks ten categories and returns a reflection prompt when a rule matches. It is a rule-based coding exercise, not a clinical assessment: a matching word alone cannot show that a thought is distorted.
What the Python detector does
The DEV Community tutorial, published October 1, 2026, describes a detector built with a Python dataclass and regular expressions. Each Distortion record holds a category name, description, patterns to look for, and reflection text. The function lowercases the input, checks each category’s patterns, and returns a result when at least one pattern for that category matches.
As an Amazon Associate I earn from qualifying purchases.
Each result includes the category, its description, the matched phrase or phrases, and a prompt intended to encourage reflection. The tutorial says the detector itself needs neither a machine-learning model nor an API. Its compact size makes it useful as a programming demonstration; it does not establish that the rules interpret a person’s meaning accurately.
Which ten categories the rules look for
The tutorial associates these categories with the following example markers. They are rule triggers, not reliable indicators on their own.
#1 Best Overall
| Category | Example markers in the tutorial |
|---|---|
| All-or-Nothing Thinking | “always,” “never,” “completely,” “totally” |
| Overgeneralization | “every time,” “always,” “never again” |
| Mental Filter | “only,” “just,” “nothing but” |
| Disqualifying Positive | “doesn’t count,” “doesn’t matter,” “just being nice” |
| Mind Reading | “they think,” “everyone knows,” “people are thinking” |
| Fortune Telling | “I’ll never,” “going to fail,” “will never” |
| Magnification | “terrible,” “awful,” “disaster,” “catastrophe,” “worst” |
| Emotional Reasoning | A pattern like “I feel … so/therefore … must/am/means” |
| Should Statements | “should,” “must,” “have to,” “ought to” |
| Labeling | Examples such as “I’m a …,” “I am a …,” “he is a …,” and “she is a …” |
The pattern lists overlap: “always” appears under both All-or-Nothing Thinking and Overgeneralization. The function can therefore return a result for each category whose patterns match. It reports one result per category, not a separate result for every matching pattern within that category.
What the worked example returns
The tutorial tests this sentence: “I always mess up. They think I’m a failure. I should just quit.” It reports four matches: All-or-Nothing Thinking, Mind Reading, Should Statements, and Labeling. Its prompts invite the reader to look for middle ground, examine evidence for assumptions about other people, reconsider rigid “should” language, and describe behavior rather than define a person by a label.
Rank #2
That output demonstrates what the listed rules return for one sentence. It is not a clinical assessment of the writer, and the prompts should be read as suggestions for reflection rather than professional guidance.
Recommended Free Tools
Can regular expressions identify cognitive distortions?
They can identify text that matches patterns chosen by a programmer. That is narrower than determining whether a thought is a cognitive distortion. “Always,” “should,” or “only” can be used in ordinary, accurate statements; a phrase such as “they think” does not reveal whether the speaker’s assumption is justified. A simple pattern match also cannot reliably establish meaning from context.
The tutorial does not report evaluation on a test dataset or measures such as precision, recall, sensitivity, specificity, or error rate. It also does not report testing for negation, sarcasm, or languages other than English. These omissions mean the article does not establish how reliably the detector distinguishes distortions from ordinary language; they are not proof that no related clinical research exists.
Use this kind of program as a learning project or exploratory reflection aid, not as a diagnostic tool or a replacement for a qualified therapist. Its prompt may help someone pause and question a thought, but the code cannot determine whether the thought is true, harmful, or clinically significant.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.What the tutorial establishes about implementation
The source describes the data structure and matching behavior, but does not specify supported Python versions or a tested runtime environment. It therefore does not establish a version-specific setup or guarantee that the example runs unchanged in every environment. Readers implementing it should check the article’s code and test it with their own Python installation.
Free tools Windows power users keep installed
One-click scans. No signup required.
The author also describes a broader toolkit that includes an API, browser tools, PDF workbooks, and a Python package. The tutorial’s build-in-public snapshot reports 226 repository clones, 2 stars, and 0 paid supporters; those are figures reported by the article, not independently verified usage measures or evidence of clinical effectiveness. Availability of the larger toolkit and any hosted services can change.
Best Value
Source
DEV Community: “Build a Cognitive Distortion Detector in 60 Lines of Python”, published October 1, 2026.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




