Record Class QuestionAndAnswer
java.lang.Object
java.lang.Record
org.ek9lang.assist.QuestionAndAnswer
- Record Components:
id- Unique question identifier (e.g., 1, 2, 3)category- Category name (e.g., "Getting Started")question- The canonical question textalternatePhrasings- Alternative ways to ask the same questionanswer- The answer text (may contain markdown formatting)ek9Example- Inline EK9 code example or file referencemigrationContext- Which developer backgrounds find this relevantkeywords- Pre-tokenized keywords for matching (no stop words)typicalErrors- Common mistakes with correct/incorrect code and explanation
public record QuestionAndAnswer(int id, String category, String question, List<String> alternatePhrasings, String answer, String ek9Example, String migrationContext, Set<String> keywords, List<TypicalError> typicalErrors)
extends Record
Holds a single Q&A entry for the EK9 knowledge base.
Used by the -q CLI for developer queries and -Q for training data export.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealternatePhrasingsrecord component.Tokenized alternate phrasings (stop words removed, synonyms resolved).answer()Returns the value of theanswerrecord component.Tokenized answer text for broad-context matching.category()Returns the value of thecategoryrecord component.Returns the value of theek9Examplerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intid()Returns the value of theidrecord component.keywords()Returns the value of thekeywordsrecord component.Keywords with synonyms resolved to canonical form.Returns the value of themigrationContextrecord component.Tokenized migration context only.Primary match tokens: resolved keywords plus tokenized canonical question and alternate phrasings.question()Returns the value of thequestionrecord component.Tokenized canonical question text (stop words removed, synonyms resolved).All searchable tokens: primary tokens plus answer text and migration context.summary()Extract a concise summary from the answer text.final StringtoString()Returns a string representation of this record class.Returns the value of thetypicalErrorsrecord component.
-
Constructor Details
-
QuestionAndAnswer
public QuestionAndAnswer(int id, String category, String question, List<String> alternatePhrasings, String answer, String ek9Example, String migrationContext, Set<String> keywords, List<TypicalError> typicalErrors) Creates an instance of aQuestionAndAnswerrecord class.- Parameters:
id- the value for theidrecord componentcategory- the value for thecategoryrecord componentquestion- the value for thequestionrecord componentalternatePhrasings- the value for thealternatePhrasingsrecord componentanswer- the value for theanswerrecord componentek9Example- the value for theek9Examplerecord componentmigrationContext- the value for themigrationContextrecord componentkeywords- the value for thekeywordsrecord componenttypicalErrors- the value for thetypicalErrorsrecord component
-
-
Method Details
-
summary
Extract a concise summary from the answer text. Uses the text before the first ALL-CAPS section header (e.g., "BASIC USAGE"). Falls back to first paragraph or word-boundary truncation at 500 chars. -
keywordTokens
-
questionTextTokens
-
alternateTokens
-
answerTokens
-
migrationTokens
-
-
searchableTokens
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
id
-
category
-
question
-
alternatePhrasings
Returns the value of thealternatePhrasingsrecord component.- Returns:
- the value of the
alternatePhrasingsrecord component
-
answer
-
ek9Example
Returns the value of theek9Examplerecord component.- Returns:
- the value of the
ek9Examplerecord component
-
migrationContext
Returns the value of themigrationContextrecord component.- Returns:
- the value of the
migrationContextrecord component
-
keywords
-
typicalErrors
Returns the value of thetypicalErrorsrecord component.- Returns:
- the value of the
typicalErrorsrecord component
-