Liking cljdoc? Tell your friends :D

com.blockether.svar.internal.humanize

AI response humanization module.

Removes AI-style phrases and patterns from LLM outputs to make responses sound more natural and human-like.

Two tiers of patterns:

  • SAFE_PATTERNS (default): AI identity, refusal, knowledge, punctuation. Unambiguously AI-generated; safe for arbitrary text.
  • AGGRESSIVE_PATTERNS (opt-in): hedging, overused verbs/adjectives/nouns, opening/closing cliches. May match valid English in non-AI text.
AI response humanization module.

Removes AI-style phrases and patterns from LLM outputs to make responses
sound more natural and human-like.

Two tiers of patterns:
- SAFE_PATTERNS (default): AI identity, refusal, knowledge, punctuation.
  Unambiguously AI-generated; safe for arbitrary text.
- AGGRESSIVE_PATTERNS (opt-in): hedging, overused verbs/adjectives/nouns,
  opening/closing cliches. May match valid English in non-AI text.
raw docstring

AGGRESSIVE_PATTERNSclj

Patterns that may match valid English. Opt-in only. Includes: hedging, overused verbs/adjectives/nouns, opening/closing cliches.

Patterns that may match valid English. Opt-in only.
Includes: hedging, overused verbs/adjectives/nouns, opening/closing cliches.
raw docstring

AI_IDENTITY_PATTERNSclj

Map of AI self-reference phrases to their replacements.

These patterns identify phrases where the AI explicitly refers to itself as an AI, language model, or assistant. Removing these makes responses sound more natural and less robotic.

Map of AI self-reference phrases to their replacements.

These patterns identify phrases where the AI explicitly refers to itself
as an AI, language model, or assistant. Removing these makes responses
sound more natural and less robotic.
raw docstring

CLOSING_CLICHE_PATTERNSclj

Map of AI-typical closing cliches to their removal (empty string).

These patterns identify and remove common AI concluding phrases that signal machine-generated content. Includes:

  • Conclusion markers ('In conclusion...', 'To summarize...')
  • Reflective fillers ('As we've seen...', 'As mentioned earlier...')
  • Takeaway templates ('The key takeaway is...', 'This demonstrates...')
Map of AI-typical closing cliches to their removal (empty string).

These patterns identify and remove common AI concluding phrases that
signal machine-generated content. Includes:
- Conclusion markers ('In conclusion...', 'To summarize...')
- Reflective fillers ('As we've seen...', 'As mentioned earlier...')
- Takeaway templates ('The key takeaway is...', 'This demonstrates...')
raw docstring

DEFAULT_PATTERNSclj

Combined map of all humanization patterns (safe + aggressive). Preserved for backward compatibility.

Combined map of all humanization patterns (safe + aggressive).
Preserved for backward compatibility.
raw docstring

HEDGING_PATTERNSclj

Map of hedging and filler phrases to their replacements.

These patterns identify phrases that add unnecessary hedging or filler to responses. Removing them makes the response more direct and confident.

Map of hedging and filler phrases to their replacements.

These patterns identify phrases that add unnecessary hedging or filler
to responses. Removing them makes the response more direct and confident.
raw docstring

humanize-dataclj

(humanize-data data)
(humanize-data data opts-or-patterns)

Recursively humanizes all strings in a data structure.

Walks through maps, vectors, lists, and sets, applying humanization to all string values while preserving the structure and types of collections. Non-string values are left unchanged. Map keys are preserved unchanged - only values are processed.

Params: data - Any. The data structure to humanize. opts-or-patterns - Map, optional. Either an opts map or a pattern map.

Returns: Any. The data structure with all strings humanized.

Recursively humanizes all strings in a data structure.

Walks through maps, vectors, lists, and sets, applying humanization
to all string values while preserving the structure and types of
collections. Non-string values are left unchanged. Map keys are
preserved unchanged - only values are processed.

Params:
`data` - Any. The data structure to humanize.
`opts-or-patterns` - Map, optional. Either an opts map or a pattern map.

Returns:
Any. The data structure with all strings humanized.
raw docstring

humanize-stringclj

(humanize-string s)
(humanize-string s opts-or-patterns)

Removes AI-style phrases from text to make it sound more natural.

Applies humanization patterns to the input string, replacing AI-specific phrases with more natural alternatives or removing them entirely. Patterns are applied in order of length (longest first) to avoid partial matches.

Uses boundary-aware matching to prevent false positives inside longer words. Protects code blocks, inline code, and URLs from modification.

Two calling conventions:

(humanize-string s) ;; safe patterns only (default) (humanize-string s {:aggressive? true}) ;; all patterns (humanize-string s {:patterns custom-map}) ;; custom pattern map

Legacy 2-arity still supported for backward compatibility: (humanize-string s pattern-map) ;; uses provided map directly

Returns: String. The humanized text. Non-string inputs returned unchanged.

Removes AI-style phrases from text to make it sound more natural.

Applies humanization patterns to the input string, replacing AI-specific
phrases with more natural alternatives or removing them entirely. Patterns
are applied in order of length (longest first) to avoid partial matches.

Uses boundary-aware matching to prevent false positives inside longer words.
Protects code blocks, inline code, and URLs from modification.

Two calling conventions:

(humanize-string s)                        ;; safe patterns only (default)
(humanize-string s {:aggressive? true})    ;; all patterns
(humanize-string s {:patterns custom-map}) ;; custom pattern map

Legacy 2-arity still supported for backward compatibility:
(humanize-string s pattern-map)            ;; uses provided map directly

Returns:
String. The humanized text. Non-string inputs returned unchanged.
raw docstring

humanizerclj

(humanizer)
(humanizer opts)

Creates a humanization function with configurable patterns.

Returns a function that removes AI-style phrases from text and data structures. The returned function can process strings, maps, vectors, lists, and sets recursively.

Params: opts - Map, optional. Configuration options:

  • :aggressive? - Boolean. Use all patterns (safe + aggressive). Default false (safe patterns only).
  • :patterns - Map. Custom pattern map. Overrides :aggressive?.

Examples: ;; Default: safe patterns only (def h (humanizer)) (h "As an AI, I think this is correct.") => "I think this is correct."

;; Aggressive: all patterns (def h (humanizer {:aggressive? true})) (h "We should leverage this.") => "We should use this."

;; Custom patterns (def h (humanizer {:patterns {"custom" "replaced"}}))

Returns: Function. A humanization function (fn [data] -> humanized-data).

Creates a humanization function with configurable patterns.

Returns a function that removes AI-style phrases from text and data
structures. The returned function can process strings, maps, vectors,
lists, and sets recursively.

Params:
`opts` - Map, optional. Configuration options:
  - `:aggressive?` - Boolean. Use all patterns (safe + aggressive).
    Default false (safe patterns only).
  - `:patterns` - Map. Custom pattern map. Overrides :aggressive?.

Examples:
;; Default: safe patterns only
(def h (humanizer))
(h "As an AI, I think this is correct.")
=> "I think this is correct."

;; Aggressive: all patterns
(def h (humanizer {:aggressive? true}))
(h "We should leverage this.")
=> "We should use this."

;; Custom patterns
(def h (humanizer {:patterns {"custom" "replaced"}}))

Returns:
Function. A humanization function `(fn [data] -> humanized-data)`.
raw docstring

KNOWLEDGE_PATTERNSclj

Map of training data and knowledge cutoff phrases to their replacements.

These patterns identify phrases where the AI refers to its training data, knowledge cutoff, or limitations. Replacing them makes the response sound more current and less robotic.

Map of training data and knowledge cutoff phrases to their replacements.

These patterns identify phrases where the AI refers to its training data,
knowledge cutoff, or limitations. Replacing them makes the response
sound more current and less robotic.
raw docstring

OPENING_CLICHE_PATTERNSclj

Map of AI-typical opening cliches to their replacements or removal.

These patterns identify and remove or simplify common AI introductory phrases that signal machine-generated content. Includes:

  • Time-based framing ('In today's digital age...')
  • Topic-staging phrases ('Let's dive into...')
  • Article starters ('This article explores...')
  • Hedged openings ('It goes without saying...')
Map of AI-typical opening cliches to their replacements or removal.

These patterns identify and remove or simplify common AI introductory
phrases that signal machine-generated content. Includes:
- Time-based framing ('In today's digital age...')
- Topic-staging phrases ('Let's dive into...')
- Article starters ('This article explores...')
- Hedged openings ('It goes without saying...')
raw docstring

OVERUSED_ADJECTIVES_PATTERNSclj

Map of AI-overused adjectives and adverbs to simpler alternatives.

These patterns replace buzzword modifiers that AI models overuse with simpler, more natural alternatives. Adverbs like 'arguably' and 'undoubtedly' are removed entirely as they add unnecessary hedging.

Includes:

  • Adjectives mapped to simpler equivalents (vibrant -> lively)
  • Adverbs mapped to empty string for removal (undoubtedly -> '')
Map of AI-overused adjectives and adverbs to simpler alternatives.

These patterns replace buzzword modifiers that AI models overuse with
simpler, more natural alternatives. Adverbs like 'arguably' and 
'undoubtedly' are removed entirely as they add unnecessary hedging.

Includes:
- Adjectives mapped to simpler equivalents (vibrant -> lively)
- Adverbs mapped to empty string for removal (undoubtedly -> '')
raw docstring

OVERUSED_NOUNS_AND_TRANSITIONS_PATTERNSclj

Map of AI-overused nouns and transition words to simpler alternatives.

These patterns replace pretentious nouns (tapestry, paradigm, ecosystem) and formal transition words (moreover, furthermore, hence) with simpler, more natural alternatives that real humans use in conversation.

Includes:

  • Metaphorical nouns -> concrete alternatives (tapestry -> mix)
  • Business jargon -> plain language (synergy -> cooperation)
  • Formal transitions -> casual connectors (moreover -> also)
Map of AI-overused nouns and transition words to simpler alternatives.

These patterns replace pretentious nouns (tapestry, paradigm, ecosystem)
and formal transition words (moreover, furthermore, hence) with simpler,
more natural alternatives that real humans use in conversation.

Includes:
- Metaphorical nouns -> concrete alternatives (tapestry -> mix)
- Business jargon -> plain language (synergy -> cooperation)
- Formal transitions -> casual connectors (moreover -> also)
raw docstring

OVERUSED_VERBS_PATTERNSclj

Map of AI-overused action verbs to simpler alternatives.

These patterns replace buzzword verbs that AI models overuse with simpler, more natural alternatives. 'Delve' is the #1 most AI-identifying word, seeing a 25,000% usage increase post-ChatGPT.

All verb forms are included: base, -ing, -ed, -s conjugations.

Map of AI-overused action verbs to simpler alternatives.

These patterns replace buzzword verbs that AI models overuse with
simpler, more natural alternatives. 'Delve' is the #1 most
AI-identifying word, seeing a 25,000% usage increase post-ChatGPT.

All verb forms are included: base, -ing, -ed, -s conjugations.
raw docstring

PUNCTUATION_PATTERNSclj

Map of punctuation patterns to their normalized forms.

These patterns normalize AI-typical punctuation overuse, particularly em dashes which are the #1 tell of AI-generated text. AI uses em dashes obsessively where humans would use commas, parentheses, or periods.

Patterns handle em dashes (—) and double hyphens (--) in various positions:

  • With spaces on both sides (middle of sentence)
  • At the start of a phrase
  • At the end of a phrase
Map of punctuation patterns to their normalized forms.

These patterns normalize AI-typical punctuation overuse, particularly
em dashes which are the #1 tell of AI-generated text. AI uses em dashes
obsessively where humans would use commas, parentheses, or periods.

Patterns handle em dashes (—) and double hyphens (--) in various positions:
- With spaces on both sides (middle of sentence)
- At the start of a phrase
- At the end of a phrase
raw docstring

REFUSAL_PATTERNSclj

Map of refusal and inability phrases to their replacements.

These patterns identify phrases where the AI refuses to do something or claims inability. Replacing them with more natural alternatives makes the response sound more conversational.

Map of refusal and inability phrases to their replacements.

These patterns identify phrases where the AI refuses to do something
or claims inability. Replacing them with more natural alternatives
makes the response sound more conversational.
raw docstring

SAFE_PATTERNSclj

Patterns that are unambiguously AI artifacts. Safe for arbitrary text. Includes: AI identity, refusal, knowledge, and punctuation patterns.

Patterns that are unambiguously AI artifacts. Safe for arbitrary text.
Includes: AI identity, refusal, knowledge, and punctuation patterns.
raw 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