I started playing around building a Tagging Engine in Python using Lists but now I’ve studied a bit more – particularly Dictionaries – I want to see how I can perfect what I was working on. Here are a couple of key things I added/changed in this program over the version I was working on earlier.
1. Using a dictionary instead of lists for faster counting and simpler recall. This is straight forward, using the get method as taught by Dr. Chuck (see Coding 101 part 7 for more details).
words = dict()
for word in wordlist :
____if word in excluded : continue
____words[word] = words.get(word,0) + 1
[Read more…] about Building a Tagging Engine in Python using Dictionaries