å

Estimating Article Details



All those numbers you see in the detail section of articles such as reading time, word count, figures, code blocks, I made them all up. Okay not really, see below.


Word + Code Count


A lot of those numbers are calculated using some Go functions (the language that this site is built on) to count the number of words after separating them from code blocks. Now one may wonder, how is that possible given that they’re practically dispersed throughout every article and are also composed of words.


{{ $wordCount := replaceRE `(?s)<code class="hljs">.*?</code>` "" .Content | countwords }}
{{ $readingTime := div (float $wordCount) 600 | math.Ceil }}
{{ $codeCount :=  .Content| strings.Count "</code>" }}

I use the following function to detect code blocks and ignore them in the word count and then I take the total count of words and divide it by a number I think most humans should be reading it at. See below.


Reading Time


If we assume that the average reader reads approximately 600 words within a minute, then we can safely assume that the estimated reading time listed above the post is accurate, which is calculated by taking the word count and dividing it by 600.

However, given that no one truly reads this quickly, especially when it comes to reading content that is dense both in content and statistics, which requires careful reading, such an estimated reading time should probably be multiple by a factor of 4 or in essence, the reading speed would be 150 words a minute, which may be slow but will allow better comprehension.

My random guess on this seems to be somewhat close to some inquiries into the matter which deem that around 200–230 words per minute is the average for reading comprehension. Whether the results of these studies is trustworthy is another question, and perhaps something to look into one day.

Hence, this function of providing estimated reading time serves no function besides to fool the reader into thinking this can be consumed faster than it can in the age of the internet.


Images


I use this particular go function to detect images throughout each article, however, it can be tricky because images can either come in the form of <img> or <figure>, or something else entirely, which can give imprecise results.


{{ $imgCount :=  .Content| strings.Count  "</figure>" }}

See also:

Article Progress Tracker