In this article, we will focus on an efficient method to count the occurrences of letter digraphs/bigrams within a given corpus, and present the results in a spreadsheet.
What are Letter Digraphs/Bigrams?
A letter digraph, also known as a bigram, is a pair of two consecutive letters in a sequence. For example, in the word "coffee", "co", "ff", "fe", and "ee" are all bigrams.
Why Count Letter Digraphs/Bigrams?
Counting letter digraphs can be useful in various fields, such as linguistics, cryptography, and data analysis. For instance, in linguistics, the frequency of bigrams can provide insights into the structure of a language, while in cryptography, letter digraphs may serve as a starting point for breaking codes.
Efficiently Counting Letter Digraphs/Bigrams
To efficiently count letter digraphs/bigrams in a corpus, a sliding window approach can be employed. This technique involves moving a window of size two (for bigrams) across the corpus, and at each step, incrementing the count of the current bigram.
Algorithm
function count_bigrams(corpus: string): Map
Displaying Results in a Spreadsheet
Once the bigram counts have been calculated, the data can be easily exported to a spreadsheet software such as Microsoft Excel or Google Sheets for further analysis.
Example Output
Here is a sample of the output in a spreadsheet format:
| Bigram | Count |
|---|---|
| th | 125 |
| he | 115 |
| in | 110 |
- Letter digraphs/bigrams are pairs of two consecutive letters in a sequence
- Efficiently counting letter digraphs/bigrams is possible using a sliding window approach
- The results can be easily exported to a spreadsheet for further analysis