filter words and classes by frequency