set() ( ), , , working = working - stopWords..., stopWords . . :
stopWords = set('the a an and'.split())
working = set('this is a test of the one working set dude'.split())
if working == working - stopWords:
print "The working set contains no stop words"
else:
print "Actually, it does"
, trie, , . trie- Python, (C) , , trie, Python, Python set(). ( Cython, ).
, , - SO: python cython.
Ultimately, of course, you have to create a simple version based on the set, check and profile it, and then try trie and Cython-trie options as possible improvements if necessary.
source
share