Class: Ace::Compressor::Atoms::CompactPolicyClassifier

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/compressor/atoms/compact_policy_classifier.rb

Overview

Classifies a source into compact-mode policy categories so the caller can choose the safest compression strategy for that document.

Constant Summary collapse

NARRATIVE_FILE_HINT_RE =

Narrative file-name hints commonly used for explanatory docs.

/(?:^|\/)(?:readme|vision|guide|guides|architecture)(?:\.|\/|$)/i
NARRATIVE_HEADING_RE =

Headings that signal descriptive/explanatory prose.

/\b(?:overview|vision|introduction|core principles|why|how it works|purpose|motivation|summary|guide)\b/i
RULE_HEADING_RE =

Headings that indicate normative policy or constraints.

/\b(?:decision|impact|policy|rule|rules|requirement|requirements|constraint|constraints)\b/i
RULE_TEXT_RE =

Modal language that usually indicates must-follow rules.

/\b(?:must|must not|never|required|requires|should|shall|cannot|can't|do not|only)\b/i

Instance Method Summary collapse

Instance Method Details

#call(source:, blocks:) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/ace/compressor/atoms/compact_policy_classifier.rb', line 18

def call(source:, blocks:)
  stats = signal_stats(source, blocks)
  doc_class = classify(stats)
  action = action_for(doc_class)
  {
    "class" => doc_class,
    "action" => action
  }
end