Display Word Frequency Menu Plugin - eliranwong/UniqueBible GitHub Wiki

Overview

This menu plugin will annotate words with how many times that Strongs word is used in the Bible. It can also be configured to highlight words with different colors depending on the word frequency.

Screenshot from 2023-12-28 13-52-33

This is useful to point out special words that are used infrequently or frequently in the Bible. For example, Luke often uses words that are only once in the entire Bible.

This will only display frequency information in Bibles that contains Strongs numbers in it, like KJVx. The plugin will display using the current active Bible and passage. If the current active Bible does not contain Strongs (any Bible that does not end with x or * or +), it will default to KJVx.

How to run it

Under "Plugins", run "Display Word Frequency". The first time you run it, it will ask to download the Statistics Words data file. If you do not have KJVx installed, it will prompt to also have it downloaded.

How to configure the highlight colors

In the marvelData/statistics folder, copy the frequency_color_mapping.txt to frequency_color_mapping_custom.txt. It will then use the frequency_color_mapping_custom.txt file instead of frequency_color_mapping.txt.

Modify the frequency_color_mapping_custom.txt with how you want the colors to be mapped.

By default, the color mapping is:

1, 1, red, red
2, 5, blue, orange
6, 10, green, green
11, 10000, black, white

If a word is only used once, it will be colored red. If it's used 2 to 5 times, it will be blue in the light theme and orange in the dark/night themes.

If there is no match with what is in the mapping file (like a word is used more than 10000 times), then it will not show the word frequency for that word. Or if you delete the third and fourth lines, it will not show word frequency information if it occurs 6 times or more.

Advanced configuration

You can have multiple color mapping files and reference those in the plugins. For example, you can create a color mapping file named frequency_color_common.txt with mapping:

100, 499, green, green
500, 999, blue, yellow
1000, 4999, orange, orange
5000, 10000, red, red

Then copy the "Display Word Frequency.py" file to "Display Word Frequency Common.py". Then modify the new file and add ":::common" to the DISPLAYWORDFREQUENCY command.

config.mainWindow.runTextCommand("DISPLAYWORDFREQUENCY:::{0}:::{1} {2}:::common".format(text, book, config.mainC))

Then you'll have a way to highlight the infrequently used words and a way to highlight the most frequently used words.

Screenshot from 2023-12-28 14-41-31

Troubleshooting

If getting error SQLError: no such table: data, the marvelData/statistics/words.stats file might be corrupted or failed to download fully. Delete that file and redownload the file by selecting in the menu "Resources", "Add", "GitHub Statistics".