Content analysis utilities for text processing and LLM workflows. Provides token estimation, word counting, reading time calculation, and slug generation for content management systems.
Content analysis utilities for text processing and LLM workflows. Provides token estimation, word counting, reading time calculation, and slug generation for content management systems.
Average characters per token for English text in GPT-style tokenizers. Based on OpenAI's rule of thumb: ~4 characters per token.
Average characters per token for English text in GPT-style tokenizers. Based on OpenAI's rule of thumb: ~4 characters per token.
Average adult reading speed in words per minute.
Average adult reading speed in words per minute.
(estimate-tokens text)(estimate-tokens text chars-per-token)Estimate the token count for a text string. Uses the ~4 characters per token heuristic for English text. Optionally accepts a custom chars-per-token ratio.
(estimate-tokens "Hello world, this is a test.") ;; => 7
(estimate-tokens "Hello world" 3.5) ;; => 4
Estimate the token count for a text string. Uses the ~4 characters per token heuristic for English text. Optionally accepts a custom chars-per-token ratio. (estimate-tokens "Hello world, this is a test.") ;; => 7 (estimate-tokens "Hello world" 3.5) ;; => 4
(reading-time text)(reading-time text wpm)Calculate estimated reading time for a text string. Returns a map with word count, minutes, and a formatted display string. Optionally accepts a custom words-per-minute rate.
(reading-time "A moderately long article with many words...") ;; => {:words 7, :minutes 1, :display "1 min read"}
(reading-time "short" 200) ;; => {:words 1, :minutes 1, :display "1 min read"}
Calculate estimated reading time for a text string.
Returns a map with word count, minutes, and a formatted display string.
Optionally accepts a custom words-per-minute rate.
(reading-time "A moderately long article with many words...")
;; => {:words 7, :minutes 1, :display "1 min read"}
(reading-time "short" 200)
;; => {:words 1, :minutes 1, :display "1 min read"}(slugify s)Convert a string into a URL-safe slug. Lowercases, replaces non-alphanumeric characters with hyphens, collapses consecutive hyphens, and trims leading/trailing hyphens.
(slugify "How to Build a REST API in Clojure") ;; => "how-to-build-a-rest-api-in-clojure"
Convert a string into a URL-safe slug. Lowercases, replaces non-alphanumeric characters with hyphens, collapses consecutive hyphens, and trims leading/trailing hyphens. (slugify "How to Build a REST API in Clojure") ;; => "how-to-build-a-rest-api-in-clojure"
(word-count text)Count the number of words in a text string. Splits on whitespace and filters out empty strings.
(word-count "Clojure is a functional language") ;; => 5
Count the number of words in a text string. Splits on whitespace and filters out empty strings. (word-count "Clojure is a functional language") ;; => 5
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |