NLTK を使用してかなり大きなデータセットの頻度分布を取得する小さなプログラムがあります。問題は、数百万ワードの後に、システムのすべての RAM を使い果たし始めることです。関連するコード行であると私が信じているのは次のとおりです。
freq_distribution = nltk.FreqDist(filtered_words) # get the frequency distribution of all the words
top_words = freq_distribution.keys()[:10] # get the top used words
bottom_words = freq_distribution.keys()[-10:] # get the least used words
キー、値ストアをディスクに書き込む方法が必要です。方法がわかりません。私は MongoDB のようなドキュメント ストアから離れ、純粋に Pythonic を維持しようとしています。誰かが何か提案があれば、私はそれをいただければ幸いです。