Skip to content

< all problems32 · Level 05, Agents

Repair: word_count says every sentence is one word

medium · repair session · Agents

Reports show every article as one word long.

The nightly report uses textstats.word_count to summarise submitted articles. Since last week every article is reported as having exactly one word, so the "average words per article" chart is a flat line at 1 and every reading time is one minute.

Reproduce:

>>> from textstats import word_count
>>> word_count("the quick brown fox")
1

Expected 4. The repo's own tests in tests/ are failing.

While you are in there: the README defines what a word is, and the report's per-article numbers have to add up to its totals, so every statistic in textstats must count words the same way. Articles arrive as Markdown, bullets and all.

Done when

  • word_count counts words the way the README defines them.
  • unique_words and average_word_length agree with it on the same text.
  • The report's format is unchanged and tests/ are untouched.

You have a coding agent with tools to list, read and edit files and run the tests. It has been given the report above, and nothing else: not the README, not what "done" means. Prompt it. It is graded on the repo it leaves behind: the repo's tests, hidden ones, and whether it left tests/ alone, and ranked on model calls.