Words to Counts
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
1 <= len(texts) <= 12- At least one word of two or more letters appears
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.