NLP / Python table

Hello experts.
I need your help.

Task: To create a table in python by showing 40 top used words

Output (table):
WORD | FREQ
‘azur’ | 52
‘vault’ | 49
‘heaven’ | 40

Variable:
words: List = ['azur', 'vault', 'heaven', 'soar', 'bright', 'pakol', 'stern', 'antrimp', 'stood', 'alon',] and more...

Thank you!

A good strategy would be to implement a histogram as a Python dict. The keys would be the words, and the values would be the count of each word.

After all the words have been counted within a for loop, you could then sort the result of calling .items() on the dict. Sort the words according to their count.

You can then loop through the sorted words, as appropriate, to create the table.

Please give it a try, and post your code, so we can help.

1 Like

Using a Counter might be useful.

2 Likes