halostatue

halostatue

Prosody - Text analysis for Reading Time - Extension for Tableau

Over the last several months, I’ve been using Tableau to rebuild my long-neglected website. Tableau is part of the Elixir Tools project headed by @mhanberg, and is built on top of MDEx by @leandrocp. This library is one of ten libraries and Elixir extensions that I built. Most of these were built with the assistance of Kiro.

Prosody is a simple content analysis library that attempts to measure the reading effort and cognitive load for mixed text and code content — like a technical blog. It provides a Tableau extension, Prosody.Tableau, that will return the reading time for code blocks.

It implements text processing in three stages:

  • parse where content is parsed with awareness of its content type (extensible, just like Tableau itself) to convert content into block types (text or code, initially)
  • analyze over the blocks to count words, with some cognitive load adjustments applied to code blocks
  • summarize over the analysis results to aggregate into reading time and metrics.

The current analysis is limited to word counting, but other analysis could be performed in the future (such as calculating content complexity such as the Flesch-Kincaid readability score) and steps could be added to merge blocks prior to analysis.

Counting words is more complex than one would imagine, as the text two words and/or fast-paced 1,234.56 www.example.com will produce 6, 8, or 12 words depending on the algorithm used. The default “balanced” algorithm produces 8, but this is configurable.

Example

content = """
# Hello World

This is some text.

```elixir
IO.puts("Hello")
```
"""

Prosody.analyze!(content, parser: :markdown)

This generates:

%{
  code: %{words: 10, lines: 1},
  text: %{words: 6},
  metadata: %{},
  words: 16,
  reading_time: 1
}

https://github.com/halostatue/prosody

Where Next?

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
387 14960 120
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
quatermain
Hello, I’m sharing my plugin here in forum after some time so it has time to mature and proof yourself. I use Claude Code daily on a pr...
New

Other Trending Topics Top

type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
bjorng
We want to introduce a new native datatype to Erlang: native records. Although replacing all tuple records with native records is not our...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New

We're in Beta

About us Mission Statement