Recently I have been on the Python Data analysis of the code (the book is based on Python2, small white I use the python3), so I next time how much some changes.
This is the NLTK frequency analysis of the 9.4 in the question about Dict_key.
The source code is this:
Operation Error:
Check the subscriptable, this link explained is still relatively clear. To put it simply, Dict_key no longer contains scriptable objects, such as List,tuple.
After a few attempts to fail, want to skip here, but the frequency of the analysis with a lot of the back, had to bite the bullet! Google half a day, found it (Ps:stackoverflow is still quite good).
That means adding a list. However, in this case, it is easy to remove the value of the highest-frequency item, but the corresponding key should not be found if the order is scrambled. So, continue to look for solutions. Thanks to the great God in the group to help, learned that there is a fixed dictionary order method--collections. Orderreddict. Refer to this blog post for specific use.
With this, you start to work, work goal-find out the number of words in the scrambled dictionary {' keyword ': ' Number '} and the number of occurrences.
So, there is it:
Operation Result:
Finally, it was a success ... But it always feels like a detour--but at least I learned to collections. orderresdict--hope to have a hero see can give a better solution.
As for Python Data analysis, it's time to read it and summarize it here.
I pass with Python3 (a)--dict and Collections.orderreddict encounter