Class QuestionRegistry

java.lang.Object
org.ek9lang.assist.QuestionRegistry

public class QuestionRegistry extends Object
Central registry for all Q&A pairs. Provides lookup by ID and category-grouped listing. Precomputes BM25F index data (IDF values and average field lengths) at construction time for efficient query-time scoring. Populated from .ek9 resource files via Ek9QaFileLoader.
  • Field Details

  • Constructor Details

  • Method Details

    • createDefault

      public static QuestionRegistry createDefault()
      Create a registry from all .ek9 QA resource files.
    • createProtocol

      public static QuestionRegistry createProtocol()
      Create a registry from protocol Q&A JSON resource files. These contain delegation, escalation, and intent protocol guidance for the ek9 -ai two-tier LLM system.
    • createDefaultWithProtocol

      public static QuestionRegistry createDefaultWithProtocol()
      Create a combined registry with both language and protocol Q&A entries. Used by training data export (-Qt) so the fine-tuned model learns both EK9 language knowledge and the delegation/escalation protocol. Protocol entry IDs are offset by 10000 to avoid collisions with language IDs.
    • getAll

      public List<QuestionAndAnswer> getAll()
    • getByCategory

      public Map<String, List<QuestionAndAnswer>> getByCategory()
    • getForCategory

      public List<QuestionAndAnswer> getForCategory(String category)
    • getById

      public Optional<QuestionAndAnswer> getById(int id)
    • size

      public int size()
    • getIdfMap

      public Map<String,Double> getIdfMap()
      Precomputed IDF (inverse document frequency) values for all tokens in the corpus. Uses BM25-style IDF: log(1 + (N - df + 0.5) / (df + 0.5)). Higher IDF means the token is rarer and more discriminating.
    • getAvgFieldLengths

      public double[] getAvgFieldLengths()
      Average token count per BM25F field across the corpus. Field order: keywords, question text, alternates, answer text, migration context.