Liking cljdoc? Tell your friends :D

mohitkhare.core

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.
raw docstring

avg-chars-per-tokenclj

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.
sourceraw docstring

avg-words-per-minuteclj

Average adult reading speed in words per minute.

Average adult reading speed in words per minute.
sourceraw docstring

estimate-tokensclj

(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
sourceraw docstring

reading-timeclj

(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"}
sourceraw docstring

slugifyclj

(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"
sourceraw docstring

word-countclj

(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
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close