Skip to content
All work

Engineering experiment · Natural language processing

Logical Fallacy Detection: text classification with machine learning

A model reads a text and assigns it to a known type of logical fallacy, the same method that sorts complaints and messages by topic.

Type
Engineering experiment
Sector
Natural language processing
Runs on
Text-classification model

What the experiment does

A logical fallacy is an argument that sounds convincing while its reasoning is flawed, such as attacking the person instead of answering their point. We built a model that reads a text and assigns it to one of several known fallacy types. It tests a skill many businesses need, which is sorting incoming text by type before anyone reads it.

How it works

The work starts when a text enters the model. The software splits the text into words and normalizes their forms, so the variants of one word count as one. It then turns the text into numbers the classifier can compare. The classifier learned beforehand from examples labeled by fallacy type. It compares the new text's numbers with what it learned and outputs the closest type. The hard part is keeping the types apart. A fallacy is a pattern in how an argument is built, and two different types can share similar words. Since the whole pipeline lives in code, we can rerun it at any time, add new examples and retrain the model.

What we can build for you

  • We sort incoming messages by topic, so a complaint or request reaches the right team without manual triage.
  • We train the model on your categories and examples, so it sorts text by the labels your team already uses.
  • We hand over the whole pipeline as code you can rerun, to add a category and retrain whenever you need.

How it is built

We wrote the whole pipeline in Python, the most widely used language for text processing and machine learning. NLTK splits the text into words and normalizes their forms; it is one of the oldest and most widely used language-processing libraries. Scikit-learn trains and applies the classifier, because it offers proven classification models that are easy to inspect and compare.

  • Python
  • Scikit-learn
  • NLTK

Common questions

Can the same method classify Arabic text?

Yes, on two conditions. The model needs labeled Arabic examples to learn from, and text preparation suited to Arabic. Arabic attaches prefixes and suffixes to words, and writes some letters, such as the hamza, in more than one form.

How accurate is the model?

We do not publish an accuracy figure for this experiment. Accuracy changes with the examples and the number of categories. It should be measured on a sample of your own texts before anyone relies on the model.