Urgent.News

What's breaking now, across thousands of outlets.

Tech

I Built a CBT Thought Journal in 50 Lines of Python ๐Ÿง 

Last week I caught myself thinking: "I always mess everything up." My therapist would recognize this as overgeneralization โ€” a cognitive distortion where one mistake becomes "everything." But I didn't want to wait for my next session to check. So I built a journal that flags distortions automatically, using a free API I deployed myself. Here's the whole thing in 50 lines. The API: CBT Thoughtโ€ฆ

Last week, the author realized they were prone to thinking: "I always mess everything up." This thought is an example of overgeneralization, a cognitive distortion where a single mistake is perceived as a complete failure. The author wanted to check this immediately, so they created a journal that automatically flags cognitive distortions using a CBT Thought Analyzer API they deployed themselves.

The API can identify 11 cognitive distortions, 8 procrastination patterns, and 4 attachment styles. The analysis is based on evidence-based keyword pattern matching and does not require an AI model.

The journal entry is implemented in 50 lines of Python code. It includes functions to analyze thoughts for cognitive distortions and procrastination patterns, as well as to write a journal entry with automatic CBT analysis. The code uses the requests library to send thoughts to the CBT analyzer API and the datetime library to add a timestamp to each journal entry. The author tested the journal with four example thoughts and received automatic analysis results for each one.

The output shows the timestamp, the thought, and any detected distortions or procrastination patterns. For each thought, the analyst provides a confidence percentage for each detected distortion or pattern, as well as suggested reframes or interventions. If no distortions or procrastination patterns are detected, the analyst notes that the thought appears balanced. The journal provides immediate feedback on thought patterns, helping users identify and challenge cognitive distortions and procrastination tendencies.

Written by urgent.news from Dev.to's reporting โ€” not their text. Machine-written โ€” may contain errors; check the original before relying on it.

Read the original at dev.to โ†’

More in Tech

When Does an Entity Stop Being a Data Model?

Most backend applications start simple. You have a few tables, a few endpoints, some business logic, and an ORM or repository layer that keeps persistence manageable. Then the application grows.

Calculus Is Fun When You Can Make a Robot Move: Understanding Differential Kinematics

let's start with two fundamental ways of describing a robot: Joint space Task space Joint Space When a robot's current configuration is represented in terms of its joint positions , we call it jointโ€ฆ

  • Calculus applied to robotics makes it engaging
  • Forward kinematics determines end effector's position
  • Differential kinematics links joint angles to end effector motion

Boring Tools, Better Work

Every developer I know has a strange relationship with their tools. We customize, we tinker, we migrate. And then one day we realize the tool we abandoned years ago still does the job better than theโ€ฆ

More from Saturday 19 September โ†’