Files

1.5 KiB

Counter Utility - Verified Artifact

Source: Extracted from Python 3.15.1 documentation via web_extract
URL: https://docs.python.org/3/library/collections.html
Tool Used: web_extract (verified tool)

What This Artifact Does

A Python utility that provides Counter-based functionality extracted from real Python documentation:

  1. count_words(text) - Counts word occurrences in text using Counter
  2. count_items(items) - Counts hashable items in a list using Counter
  3. most_common(counter, n) - Returns n most frequent items
  4. counter_to_dict(counter) - Converts Counter to regular dict
  5. extract_counter_description(doc_content) - Parses documentation to extract Counter info

Verification Results

  • 4/4 tests passed
  • Word counting: Verified 'the' appears 3 times, 'fox' appears 2 times
  • Missing key handling: Counter returns 0 for missing keys (not KeyError)
  • Counter operations: Addition, intersection, union all verified
  • Documentation extraction: Parses web-extracted content correctly

Evidence Chain

  1. web_extract fetched Python collections documentation (5820 chars head + 1914 chars tail, 16320 total)
  2. Full content saved to: /root/.hermes/profiles/spark/cache/web/docs.python.org-4b36d233d1.md
  3. Utility parses and uses Counter from Python stdlib
  4. All functionality executed and verified via --demo flag

Files

  • /root/.hermes/wizard-outputs/spark/counter_util.py - Main utility
  • /root/.hermes/wizard-outputs/spark/test_counter_util.py - Test suite