In the beginning, I would like to state that this is not meant to be a discussion. But I would like to receive only suggestions for possible solutions or, at least, a comment on my proposed solution:

I'm in my first steps to create a small tool that should help evaluate data from my master thesis experiment.

In this experiment, subjects had to correct a small text. Small errors are built into this text.

My intent is to write a python tool that:

  1. load texts from a CSV file (with subject ID and corrected text)
  2. compare each corrected text from each subject with the original correct text
  3. determine the error found count for each subject
  4. write into CSV this error count.

How would you implement 2. and 3.?

My ideas are:

  • save original deposit text into dict A.
  • loop for each CSV row and get this text from subject
  • load text into another dict B.
  • loop for dict A and B and compare. Add a counter which counts either error or correct changes (*).

(*) I'm unsure if I should use the correct text or the incorrect text for comparison with the corrected subjects text.

I am curious what ideas you have and/or whether you also know a suitable package for me.

  • 2
  • @gnat My intent is not (!) to discuss my problem, I would like to get ideas from others on how they would implement this on a conceptual level. Or, if that is not desired, to receive a comment, on my ideas.
    – Chris B.
    Apr 25 at 12:52
  • Moreover, the method of brainstorming is not to comment your or others ideas, so that a discussion could arise. Brainstorming is just a method to capture all upcoming thoughts.
    – Chris B.
    Apr 25 at 12:54

1 Answer 1


I'd have a look at the Levenshtein algorithm (install using pip install Levenshtein) on a word level:

import Levenshtein, re

pattern = r"[\w']+|[.,!?;]"

def words(s):
    return re.findall(pattern,s)

good = "In this experiment, subjects had to correct a small text. Small errors are built into this text."
bad = "In this experment, subjects had too correct small text. Samll errors are build into this test!"

Levenshtein.editops(words(bad), words(good))

You can use it to extract a list of "good" edits which transform the error-ridden text into the correct text to count the number of corrections that must be made.

Then you use it to count the differences between the good text and the corrected text by the subject. If it's 0, the subject corrected all errors, otherwise they missed that many errors or made miscorrections.

Experiment a bit with this to see how you can use it to achieve what you need.

Not the answer you're looking for? Browse other questions tagged or ask your own question.