FunctionRacerProblemsRace

Words to Counts

Mediumscikit-learnPython

Text has to become numbers before a model can use it. Turn texts into word counts with scikit-learn's default settings (lowercase, words of two or more letters or digits, punctuation dropped) and return a dict from each word to how many times it appears in all the texts together.

Example 1

texts ["The cat sat","a cat and a Dog","I saw 2 dogs!"]
returns {"the":1,"cat":2,"sat":1,"and":1,"dog":1,"saw":1,"dogs":1}

Capitals are lowered, and the one-letter words "a" and "I" and the single digit 2 are dropped.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More scikit-learn problems