@learning-commons/evaluators 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +161 -14
- package/dist/index.cjs +471 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +192 -5
- package/dist/index.d.ts +192 -5
- package/dist/index.js +468 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -553,6 +553,57 @@ declare const VocabularyComplexitySchema: z.ZodObject<{
|
|
|
553
553
|
}>;
|
|
554
554
|
type VocabularyInternal = z.infer<typeof VocabularyComplexitySchema>;
|
|
555
555
|
|
|
556
|
+
/**
|
|
557
|
+
* Subject Matter Knowledge evaluation output schema
|
|
558
|
+
*/
|
|
559
|
+
declare const SmkOutputSchema: z.ZodObject<{
|
|
560
|
+
identified_topics: z.ZodArray<z.ZodString, "many">;
|
|
561
|
+
curriculum_check: z.ZodString;
|
|
562
|
+
assumptions_and_scaffolding: z.ZodString;
|
|
563
|
+
friction_analysis: z.ZodString;
|
|
564
|
+
complexity_score: z.ZodEnum<["Slightly complex", "Moderately complex", "Very complex", "Exceedingly complex"]>;
|
|
565
|
+
reasoning: z.ZodString;
|
|
566
|
+
}, "strip", z.ZodTypeAny, {
|
|
567
|
+
reasoning: string;
|
|
568
|
+
complexity_score: "Slightly complex" | "Moderately complex" | "Very complex" | "Exceedingly complex";
|
|
569
|
+
identified_topics: string[];
|
|
570
|
+
curriculum_check: string;
|
|
571
|
+
assumptions_and_scaffolding: string;
|
|
572
|
+
friction_analysis: string;
|
|
573
|
+
}, {
|
|
574
|
+
reasoning: string;
|
|
575
|
+
complexity_score: "Slightly complex" | "Moderately complex" | "Very complex" | "Exceedingly complex";
|
|
576
|
+
identified_topics: string[];
|
|
577
|
+
curriculum_check: string;
|
|
578
|
+
assumptions_and_scaffolding: string;
|
|
579
|
+
friction_analysis: string;
|
|
580
|
+
}>;
|
|
581
|
+
type SmkInternal = z.infer<typeof SmkOutputSchema>;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Conventionality evaluation output schema
|
|
585
|
+
*/
|
|
586
|
+
declare const ConventionalityOutputSchema: z.ZodObject<{
|
|
587
|
+
conventionality_features: z.ZodArray<z.ZodString, "many">;
|
|
588
|
+
grade_context: z.ZodString;
|
|
589
|
+
instructional_insights: z.ZodString;
|
|
590
|
+
complexity_score: z.ZodEnum<["Slightly complex", "Moderately complex", "Very complex", "Exceedingly complex"]>;
|
|
591
|
+
reasoning: z.ZodString;
|
|
592
|
+
}, "strip", z.ZodTypeAny, {
|
|
593
|
+
reasoning: string;
|
|
594
|
+
complexity_score: "Slightly complex" | "Moderately complex" | "Very complex" | "Exceedingly complex";
|
|
595
|
+
conventionality_features: string[];
|
|
596
|
+
grade_context: string;
|
|
597
|
+
instructional_insights: string;
|
|
598
|
+
}, {
|
|
599
|
+
reasoning: string;
|
|
600
|
+
complexity_score: "Slightly complex" | "Moderately complex" | "Very complex" | "Exceedingly complex";
|
|
601
|
+
conventionality_features: string[];
|
|
602
|
+
grade_context: string;
|
|
603
|
+
instructional_insights: string;
|
|
604
|
+
}>;
|
|
605
|
+
type ConventionalityInternal = z.infer<typeof ConventionalityOutputSchema>;
|
|
606
|
+
|
|
556
607
|
/**
|
|
557
608
|
* Evaluation status
|
|
558
609
|
*/
|
|
@@ -1024,6 +1075,132 @@ declare class GradeLevelAppropriatenessEvaluator extends BaseEvaluator {
|
|
|
1024
1075
|
*/
|
|
1025
1076
|
declare function evaluateGradeLevelAppropriateness(text: string, config: BaseEvaluatorConfig): Promise<EvaluationResult<GradeBand, GradeLevelAppropriatenessInternal>>;
|
|
1026
1077
|
|
|
1078
|
+
/**
|
|
1079
|
+
* Subject Matter Knowledge (SMK) Evaluator
|
|
1080
|
+
*
|
|
1081
|
+
* Evaluates the background knowledge demands of educational texts relative to grade level.
|
|
1082
|
+
* Determines how much prior subject knowledge a student needs to comprehend the text.
|
|
1083
|
+
*
|
|
1084
|
+
* Based on the Common Core Qualitative Text Complexity Rubric with 4 levels:
|
|
1085
|
+
* - Slightly complex
|
|
1086
|
+
* - Moderately complex
|
|
1087
|
+
* - Very complex
|
|
1088
|
+
* - Exceedingly complex
|
|
1089
|
+
*
|
|
1090
|
+
* @example
|
|
1091
|
+
* ```typescript
|
|
1092
|
+
* const evaluator = new SmkEvaluator({
|
|
1093
|
+
* googleApiKey: process.env.GOOGLE_API_KEY
|
|
1094
|
+
* });
|
|
1095
|
+
*
|
|
1096
|
+
* const result = await evaluator.evaluate(text, "6");
|
|
1097
|
+
* console.log(result.score); // "Moderately complex"
|
|
1098
|
+
* console.log(result.reasoning);
|
|
1099
|
+
* ```
|
|
1100
|
+
*/
|
|
1101
|
+
declare class SmkEvaluator extends BaseEvaluator {
|
|
1102
|
+
static readonly metadata: {
|
|
1103
|
+
id: string;
|
|
1104
|
+
name: string;
|
|
1105
|
+
description: string;
|
|
1106
|
+
supportedGrades: readonly ["3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
|
|
1107
|
+
requiresGoogleKey: boolean;
|
|
1108
|
+
requiresOpenAIKey: boolean;
|
|
1109
|
+
};
|
|
1110
|
+
private provider;
|
|
1111
|
+
constructor(config: BaseEvaluatorConfig);
|
|
1112
|
+
/**
|
|
1113
|
+
* Evaluate subject matter knowledge complexity for a given text and grade level
|
|
1114
|
+
*
|
|
1115
|
+
* @param text - The text to evaluate
|
|
1116
|
+
* @param grade - The target grade level (3-12)
|
|
1117
|
+
* @returns Evaluation result with complexity score and detailed analysis
|
|
1118
|
+
* @throws {ValidationError} If text is empty, too short/long, or grade is invalid
|
|
1119
|
+
* @throws {APIError} If LLM API calls fail (includes AuthenticationError, RateLimitError, NetworkError, TimeoutError)
|
|
1120
|
+
*/
|
|
1121
|
+
evaluate(text: string, grade: string): Promise<EvaluationResult<TextComplexityLevel, SmkInternal>>;
|
|
1122
|
+
/**
|
|
1123
|
+
* Run the SMK evaluation LLM call
|
|
1124
|
+
*/
|
|
1125
|
+
private evaluateSmk;
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Functional API for SMK evaluation
|
|
1129
|
+
*
|
|
1130
|
+
* @example
|
|
1131
|
+
* ```typescript
|
|
1132
|
+
* const result = await evaluateSmk(
|
|
1133
|
+
* "Hydraulic propulsion works by sucking water at the bow and forcing it sternward.",
|
|
1134
|
+
* "10",
|
|
1135
|
+
* { googleApiKey: process.env.GOOGLE_API_KEY }
|
|
1136
|
+
* );
|
|
1137
|
+
* ```
|
|
1138
|
+
*/
|
|
1139
|
+
declare function evaluateSmk(text: string, grade: string, config: BaseEvaluatorConfig): Promise<EvaluationResult<TextComplexityLevel, SmkInternal>>;
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* Conventionality Evaluator
|
|
1143
|
+
*
|
|
1144
|
+
* Evaluates how explicit, literal, and straightforward a text's meaning is versus
|
|
1145
|
+
* how abstract, ironic, figurative, or archaic it is for the target grade level.
|
|
1146
|
+
*
|
|
1147
|
+
* Based on the Common Core Qualitative Text Complexity Rubric with 4 levels:
|
|
1148
|
+
* - Slightly complex
|
|
1149
|
+
* - Moderately complex
|
|
1150
|
+
* - Very complex
|
|
1151
|
+
* - Exceedingly complex
|
|
1152
|
+
*
|
|
1153
|
+
* @example
|
|
1154
|
+
* ```typescript
|
|
1155
|
+
* const evaluator = new ConventionalityEvaluator({
|
|
1156
|
+
* googleApiKey: process.env.GOOGLE_API_KEY
|
|
1157
|
+
* });
|
|
1158
|
+
*
|
|
1159
|
+
* const result = await evaluator.evaluate(text, "6");
|
|
1160
|
+
* console.log(result.score); // "Moderately complex"
|
|
1161
|
+
* console.log(result.reasoning);
|
|
1162
|
+
* ```
|
|
1163
|
+
*/
|
|
1164
|
+
declare class ConventionalityEvaluator extends BaseEvaluator {
|
|
1165
|
+
static readonly metadata: {
|
|
1166
|
+
id: string;
|
|
1167
|
+
name: string;
|
|
1168
|
+
description: string;
|
|
1169
|
+
supportedGrades: readonly ["3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
|
|
1170
|
+
requiresGoogleKey: boolean;
|
|
1171
|
+
requiresOpenAIKey: boolean;
|
|
1172
|
+
};
|
|
1173
|
+
private provider;
|
|
1174
|
+
constructor(config: BaseEvaluatorConfig);
|
|
1175
|
+
/**
|
|
1176
|
+
* Evaluate conventionality complexity for a given text and grade level
|
|
1177
|
+
*
|
|
1178
|
+
* @param text - The text to evaluate
|
|
1179
|
+
* @param grade - The target grade level (3-12)
|
|
1180
|
+
* @returns Evaluation result with complexity score and detailed analysis
|
|
1181
|
+
* @throws {ValidationError} If text is empty, too short/long, or grade is invalid
|
|
1182
|
+
* @throws {APIError} If LLM API calls fail (includes AuthenticationError, RateLimitError, NetworkError, TimeoutError)
|
|
1183
|
+
*/
|
|
1184
|
+
evaluate(text: string, grade: string): Promise<EvaluationResult<TextComplexityLevel, ConventionalityInternal>>;
|
|
1185
|
+
/**
|
|
1186
|
+
* Run the Conventionality evaluation LLM call
|
|
1187
|
+
*/
|
|
1188
|
+
private evaluateConventionality;
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Functional API for Conventionality evaluation
|
|
1192
|
+
*
|
|
1193
|
+
* @example
|
|
1194
|
+
* ```typescript
|
|
1195
|
+
* const result = await evaluateConventionality(
|
|
1196
|
+
* "The author uses sustained irony to critique societal norms.",
|
|
1197
|
+
* "10",
|
|
1198
|
+
* { googleApiKey: process.env.GOOGLE_API_KEY }
|
|
1199
|
+
* );
|
|
1200
|
+
* ```
|
|
1201
|
+
*/
|
|
1202
|
+
declare function evaluateConventionality(text: string, grade: string, config: BaseEvaluatorConfig): Promise<EvaluationResult<TextComplexityLevel, ConventionalityInternal>>;
|
|
1203
|
+
|
|
1027
1204
|
/**
|
|
1028
1205
|
* Result map returned by TextComplexityEvaluator.
|
|
1029
1206
|
* Each key holds the full evaluation result from its sub-evaluator, or an error if it failed.
|
|
@@ -1035,16 +1212,24 @@ interface TextComplexityResult {
|
|
|
1035
1212
|
sentenceStructure: EvaluationResult<TextComplexityLevel, SentenceStructureInternal> | {
|
|
1036
1213
|
error: Error;
|
|
1037
1214
|
};
|
|
1215
|
+
subjectMatterKnowledge: EvaluationResult<TextComplexityLevel, SmkInternal> | {
|
|
1216
|
+
error: Error;
|
|
1217
|
+
};
|
|
1218
|
+
conventionality: EvaluationResult<TextComplexityLevel, ConventionalityInternal> | {
|
|
1219
|
+
error: Error;
|
|
1220
|
+
};
|
|
1038
1221
|
}
|
|
1039
1222
|
/**
|
|
1040
1223
|
* Text Complexity Evaluator
|
|
1041
1224
|
*
|
|
1042
|
-
* Composite evaluator that analyzes
|
|
1043
|
-
* Runs
|
|
1225
|
+
* Composite evaluator that analyzes vocabulary, sentence structure, subject matter knowledge, and conventionality.
|
|
1226
|
+
* Runs all evaluations in parallel with concurrency control to avoid rate limiting.
|
|
1044
1227
|
*
|
|
1045
1228
|
* Uses:
|
|
1046
1229
|
* - VocabularyEvaluator (Google Gemini 2.5 Pro + OpenAI GPT-4o)
|
|
1047
1230
|
* - SentenceStructureEvaluator (OpenAI GPT-4o)
|
|
1231
|
+
* - SmkEvaluator (Google Gemini 3 Flash Preview)
|
|
1232
|
+
* - ConventionalityEvaluator (Google Gemini 3 Flash Preview)
|
|
1048
1233
|
*
|
|
1049
1234
|
* @example
|
|
1050
1235
|
* ```typescript
|
|
@@ -1070,13 +1255,15 @@ declare class TextComplexityEvaluator extends BaseEvaluator {
|
|
|
1070
1255
|
};
|
|
1071
1256
|
private vocabularyEvaluator;
|
|
1072
1257
|
private sentenceStructureEvaluator;
|
|
1258
|
+
private smkEvaluator;
|
|
1259
|
+
private conventionalityEvaluator;
|
|
1073
1260
|
private limit;
|
|
1074
1261
|
constructor(config: BaseEvaluatorConfig);
|
|
1075
1262
|
/**
|
|
1076
1263
|
* Evaluate text complexity for a given text and grade level
|
|
1077
1264
|
*
|
|
1078
|
-
* Runs vocabulary
|
|
1079
|
-
* If
|
|
1265
|
+
* Runs vocabulary, sentence structure, and SMK evaluations in parallel with concurrency control.
|
|
1266
|
+
* If all three sub-evaluators fail, throws an error. Otherwise returns a result map where
|
|
1080
1267
|
* failed sub-evaluators are represented as `{ error: Error }`.
|
|
1081
1268
|
*
|
|
1082
1269
|
* @param text - The text to evaluate
|
|
@@ -1139,4 +1326,4 @@ declare function addEngineeredFeatures(analysis: SentenceAnalysis): SentenceFeat
|
|
|
1139
1326
|
*/
|
|
1140
1327
|
declare function featuresToJSON(features: SentenceFeatures, decimals?: number, castToInt?: boolean): string;
|
|
1141
1328
|
|
|
1142
|
-
export { APIError, AuthenticationError, type BaseEvaluatorConfig, type ComplexityClassification, ComplexityClassificationSchema, ConfigurationError, type EvaluationError, type EvaluationMetadata, type EvaluationResult, EvaluatorError, type EvaluatorMetadata, GradeBand, GradeLevelAppropriatenessEvaluator, type GradeLevelAppropriatenessInternal, GradeLevelAppropriatenessSchema, type LLMProvider, type LLMRequest, type LLMResponse, type LogContext, LogLevel, type Logger, type Message, NetworkError, type ProviderConfig, RateLimitError, type ReadabilityMetrics, type SentenceAnalysis, SentenceAnalysisSchema, type SentenceFeatures, SentenceStructureEvaluator, type SentenceStructureInternal, type TelemetryOptions, TextComplexityEvaluator, TextComplexityLevel, type TextComplexityResult, type TextGenerationResponse, TimeoutError, ValidationError, VocabularyEvaluator, type VocabularyInternal, addEngineeredFeatures, calculateFleschKincaidGrade, calculateReadabilityMetrics, evaluateGradeLevelAppropriateness, evaluateSentenceStructure, evaluateTextComplexity, evaluateVocabulary, featuresToJSON };
|
|
1329
|
+
export { APIError, AuthenticationError, type BaseEvaluatorConfig, type ComplexityClassification, ComplexityClassificationSchema, ConfigurationError, ConventionalityEvaluator, type ConventionalityInternal, type EvaluationError, type EvaluationMetadata, type EvaluationResult, EvaluatorError, type EvaluatorMetadata, GradeBand, GradeLevelAppropriatenessEvaluator, type GradeLevelAppropriatenessInternal, GradeLevelAppropriatenessSchema, type LLMProvider, type LLMRequest, type LLMResponse, type LogContext, LogLevel, type Logger, type Message, NetworkError, type ProviderConfig, RateLimitError, type ReadabilityMetrics, type SentenceAnalysis, SentenceAnalysisSchema, type SentenceFeatures, SentenceStructureEvaluator, type SentenceStructureInternal, SmkEvaluator, type SmkInternal, type TelemetryOptions, TextComplexityEvaluator, TextComplexityLevel, type TextComplexityResult, type TextGenerationResponse, TimeoutError, ValidationError, VocabularyEvaluator, type VocabularyInternal, addEngineeredFeatures, calculateFleschKincaidGrade, calculateReadabilityMetrics, evaluateConventionality, evaluateGradeLevelAppropriateness, evaluateSentenceStructure, evaluateSmk, evaluateTextComplexity, evaluateVocabulary, featuresToJSON };
|
package/dist/index.d.ts
CHANGED
|
@@ -553,6 +553,57 @@ declare const VocabularyComplexitySchema: z.ZodObject<{
|
|
|
553
553
|
}>;
|
|
554
554
|
type VocabularyInternal = z.infer<typeof VocabularyComplexitySchema>;
|
|
555
555
|
|
|
556
|
+
/**
|
|
557
|
+
* Subject Matter Knowledge evaluation output schema
|
|
558
|
+
*/
|
|
559
|
+
declare const SmkOutputSchema: z.ZodObject<{
|
|
560
|
+
identified_topics: z.ZodArray<z.ZodString, "many">;
|
|
561
|
+
curriculum_check: z.ZodString;
|
|
562
|
+
assumptions_and_scaffolding: z.ZodString;
|
|
563
|
+
friction_analysis: z.ZodString;
|
|
564
|
+
complexity_score: z.ZodEnum<["Slightly complex", "Moderately complex", "Very complex", "Exceedingly complex"]>;
|
|
565
|
+
reasoning: z.ZodString;
|
|
566
|
+
}, "strip", z.ZodTypeAny, {
|
|
567
|
+
reasoning: string;
|
|
568
|
+
complexity_score: "Slightly complex" | "Moderately complex" | "Very complex" | "Exceedingly complex";
|
|
569
|
+
identified_topics: string[];
|
|
570
|
+
curriculum_check: string;
|
|
571
|
+
assumptions_and_scaffolding: string;
|
|
572
|
+
friction_analysis: string;
|
|
573
|
+
}, {
|
|
574
|
+
reasoning: string;
|
|
575
|
+
complexity_score: "Slightly complex" | "Moderately complex" | "Very complex" | "Exceedingly complex";
|
|
576
|
+
identified_topics: string[];
|
|
577
|
+
curriculum_check: string;
|
|
578
|
+
assumptions_and_scaffolding: string;
|
|
579
|
+
friction_analysis: string;
|
|
580
|
+
}>;
|
|
581
|
+
type SmkInternal = z.infer<typeof SmkOutputSchema>;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Conventionality evaluation output schema
|
|
585
|
+
*/
|
|
586
|
+
declare const ConventionalityOutputSchema: z.ZodObject<{
|
|
587
|
+
conventionality_features: z.ZodArray<z.ZodString, "many">;
|
|
588
|
+
grade_context: z.ZodString;
|
|
589
|
+
instructional_insights: z.ZodString;
|
|
590
|
+
complexity_score: z.ZodEnum<["Slightly complex", "Moderately complex", "Very complex", "Exceedingly complex"]>;
|
|
591
|
+
reasoning: z.ZodString;
|
|
592
|
+
}, "strip", z.ZodTypeAny, {
|
|
593
|
+
reasoning: string;
|
|
594
|
+
complexity_score: "Slightly complex" | "Moderately complex" | "Very complex" | "Exceedingly complex";
|
|
595
|
+
conventionality_features: string[];
|
|
596
|
+
grade_context: string;
|
|
597
|
+
instructional_insights: string;
|
|
598
|
+
}, {
|
|
599
|
+
reasoning: string;
|
|
600
|
+
complexity_score: "Slightly complex" | "Moderately complex" | "Very complex" | "Exceedingly complex";
|
|
601
|
+
conventionality_features: string[];
|
|
602
|
+
grade_context: string;
|
|
603
|
+
instructional_insights: string;
|
|
604
|
+
}>;
|
|
605
|
+
type ConventionalityInternal = z.infer<typeof ConventionalityOutputSchema>;
|
|
606
|
+
|
|
556
607
|
/**
|
|
557
608
|
* Evaluation status
|
|
558
609
|
*/
|
|
@@ -1024,6 +1075,132 @@ declare class GradeLevelAppropriatenessEvaluator extends BaseEvaluator {
|
|
|
1024
1075
|
*/
|
|
1025
1076
|
declare function evaluateGradeLevelAppropriateness(text: string, config: BaseEvaluatorConfig): Promise<EvaluationResult<GradeBand, GradeLevelAppropriatenessInternal>>;
|
|
1026
1077
|
|
|
1078
|
+
/**
|
|
1079
|
+
* Subject Matter Knowledge (SMK) Evaluator
|
|
1080
|
+
*
|
|
1081
|
+
* Evaluates the background knowledge demands of educational texts relative to grade level.
|
|
1082
|
+
* Determines how much prior subject knowledge a student needs to comprehend the text.
|
|
1083
|
+
*
|
|
1084
|
+
* Based on the Common Core Qualitative Text Complexity Rubric with 4 levels:
|
|
1085
|
+
* - Slightly complex
|
|
1086
|
+
* - Moderately complex
|
|
1087
|
+
* - Very complex
|
|
1088
|
+
* - Exceedingly complex
|
|
1089
|
+
*
|
|
1090
|
+
* @example
|
|
1091
|
+
* ```typescript
|
|
1092
|
+
* const evaluator = new SmkEvaluator({
|
|
1093
|
+
* googleApiKey: process.env.GOOGLE_API_KEY
|
|
1094
|
+
* });
|
|
1095
|
+
*
|
|
1096
|
+
* const result = await evaluator.evaluate(text, "6");
|
|
1097
|
+
* console.log(result.score); // "Moderately complex"
|
|
1098
|
+
* console.log(result.reasoning);
|
|
1099
|
+
* ```
|
|
1100
|
+
*/
|
|
1101
|
+
declare class SmkEvaluator extends BaseEvaluator {
|
|
1102
|
+
static readonly metadata: {
|
|
1103
|
+
id: string;
|
|
1104
|
+
name: string;
|
|
1105
|
+
description: string;
|
|
1106
|
+
supportedGrades: readonly ["3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
|
|
1107
|
+
requiresGoogleKey: boolean;
|
|
1108
|
+
requiresOpenAIKey: boolean;
|
|
1109
|
+
};
|
|
1110
|
+
private provider;
|
|
1111
|
+
constructor(config: BaseEvaluatorConfig);
|
|
1112
|
+
/**
|
|
1113
|
+
* Evaluate subject matter knowledge complexity for a given text and grade level
|
|
1114
|
+
*
|
|
1115
|
+
* @param text - The text to evaluate
|
|
1116
|
+
* @param grade - The target grade level (3-12)
|
|
1117
|
+
* @returns Evaluation result with complexity score and detailed analysis
|
|
1118
|
+
* @throws {ValidationError} If text is empty, too short/long, or grade is invalid
|
|
1119
|
+
* @throws {APIError} If LLM API calls fail (includes AuthenticationError, RateLimitError, NetworkError, TimeoutError)
|
|
1120
|
+
*/
|
|
1121
|
+
evaluate(text: string, grade: string): Promise<EvaluationResult<TextComplexityLevel, SmkInternal>>;
|
|
1122
|
+
/**
|
|
1123
|
+
* Run the SMK evaluation LLM call
|
|
1124
|
+
*/
|
|
1125
|
+
private evaluateSmk;
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Functional API for SMK evaluation
|
|
1129
|
+
*
|
|
1130
|
+
* @example
|
|
1131
|
+
* ```typescript
|
|
1132
|
+
* const result = await evaluateSmk(
|
|
1133
|
+
* "Hydraulic propulsion works by sucking water at the bow and forcing it sternward.",
|
|
1134
|
+
* "10",
|
|
1135
|
+
* { googleApiKey: process.env.GOOGLE_API_KEY }
|
|
1136
|
+
* );
|
|
1137
|
+
* ```
|
|
1138
|
+
*/
|
|
1139
|
+
declare function evaluateSmk(text: string, grade: string, config: BaseEvaluatorConfig): Promise<EvaluationResult<TextComplexityLevel, SmkInternal>>;
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* Conventionality Evaluator
|
|
1143
|
+
*
|
|
1144
|
+
* Evaluates how explicit, literal, and straightforward a text's meaning is versus
|
|
1145
|
+
* how abstract, ironic, figurative, or archaic it is for the target grade level.
|
|
1146
|
+
*
|
|
1147
|
+
* Based on the Common Core Qualitative Text Complexity Rubric with 4 levels:
|
|
1148
|
+
* - Slightly complex
|
|
1149
|
+
* - Moderately complex
|
|
1150
|
+
* - Very complex
|
|
1151
|
+
* - Exceedingly complex
|
|
1152
|
+
*
|
|
1153
|
+
* @example
|
|
1154
|
+
* ```typescript
|
|
1155
|
+
* const evaluator = new ConventionalityEvaluator({
|
|
1156
|
+
* googleApiKey: process.env.GOOGLE_API_KEY
|
|
1157
|
+
* });
|
|
1158
|
+
*
|
|
1159
|
+
* const result = await evaluator.evaluate(text, "6");
|
|
1160
|
+
* console.log(result.score); // "Moderately complex"
|
|
1161
|
+
* console.log(result.reasoning);
|
|
1162
|
+
* ```
|
|
1163
|
+
*/
|
|
1164
|
+
declare class ConventionalityEvaluator extends BaseEvaluator {
|
|
1165
|
+
static readonly metadata: {
|
|
1166
|
+
id: string;
|
|
1167
|
+
name: string;
|
|
1168
|
+
description: string;
|
|
1169
|
+
supportedGrades: readonly ["3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
|
|
1170
|
+
requiresGoogleKey: boolean;
|
|
1171
|
+
requiresOpenAIKey: boolean;
|
|
1172
|
+
};
|
|
1173
|
+
private provider;
|
|
1174
|
+
constructor(config: BaseEvaluatorConfig);
|
|
1175
|
+
/**
|
|
1176
|
+
* Evaluate conventionality complexity for a given text and grade level
|
|
1177
|
+
*
|
|
1178
|
+
* @param text - The text to evaluate
|
|
1179
|
+
* @param grade - The target grade level (3-12)
|
|
1180
|
+
* @returns Evaluation result with complexity score and detailed analysis
|
|
1181
|
+
* @throws {ValidationError} If text is empty, too short/long, or grade is invalid
|
|
1182
|
+
* @throws {APIError} If LLM API calls fail (includes AuthenticationError, RateLimitError, NetworkError, TimeoutError)
|
|
1183
|
+
*/
|
|
1184
|
+
evaluate(text: string, grade: string): Promise<EvaluationResult<TextComplexityLevel, ConventionalityInternal>>;
|
|
1185
|
+
/**
|
|
1186
|
+
* Run the Conventionality evaluation LLM call
|
|
1187
|
+
*/
|
|
1188
|
+
private evaluateConventionality;
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Functional API for Conventionality evaluation
|
|
1192
|
+
*
|
|
1193
|
+
* @example
|
|
1194
|
+
* ```typescript
|
|
1195
|
+
* const result = await evaluateConventionality(
|
|
1196
|
+
* "The author uses sustained irony to critique societal norms.",
|
|
1197
|
+
* "10",
|
|
1198
|
+
* { googleApiKey: process.env.GOOGLE_API_KEY }
|
|
1199
|
+
* );
|
|
1200
|
+
* ```
|
|
1201
|
+
*/
|
|
1202
|
+
declare function evaluateConventionality(text: string, grade: string, config: BaseEvaluatorConfig): Promise<EvaluationResult<TextComplexityLevel, ConventionalityInternal>>;
|
|
1203
|
+
|
|
1027
1204
|
/**
|
|
1028
1205
|
* Result map returned by TextComplexityEvaluator.
|
|
1029
1206
|
* Each key holds the full evaluation result from its sub-evaluator, or an error if it failed.
|
|
@@ -1035,16 +1212,24 @@ interface TextComplexityResult {
|
|
|
1035
1212
|
sentenceStructure: EvaluationResult<TextComplexityLevel, SentenceStructureInternal> | {
|
|
1036
1213
|
error: Error;
|
|
1037
1214
|
};
|
|
1215
|
+
subjectMatterKnowledge: EvaluationResult<TextComplexityLevel, SmkInternal> | {
|
|
1216
|
+
error: Error;
|
|
1217
|
+
};
|
|
1218
|
+
conventionality: EvaluationResult<TextComplexityLevel, ConventionalityInternal> | {
|
|
1219
|
+
error: Error;
|
|
1220
|
+
};
|
|
1038
1221
|
}
|
|
1039
1222
|
/**
|
|
1040
1223
|
* Text Complexity Evaluator
|
|
1041
1224
|
*
|
|
1042
|
-
* Composite evaluator that analyzes
|
|
1043
|
-
* Runs
|
|
1225
|
+
* Composite evaluator that analyzes vocabulary, sentence structure, subject matter knowledge, and conventionality.
|
|
1226
|
+
* Runs all evaluations in parallel with concurrency control to avoid rate limiting.
|
|
1044
1227
|
*
|
|
1045
1228
|
* Uses:
|
|
1046
1229
|
* - VocabularyEvaluator (Google Gemini 2.5 Pro + OpenAI GPT-4o)
|
|
1047
1230
|
* - SentenceStructureEvaluator (OpenAI GPT-4o)
|
|
1231
|
+
* - SmkEvaluator (Google Gemini 3 Flash Preview)
|
|
1232
|
+
* - ConventionalityEvaluator (Google Gemini 3 Flash Preview)
|
|
1048
1233
|
*
|
|
1049
1234
|
* @example
|
|
1050
1235
|
* ```typescript
|
|
@@ -1070,13 +1255,15 @@ declare class TextComplexityEvaluator extends BaseEvaluator {
|
|
|
1070
1255
|
};
|
|
1071
1256
|
private vocabularyEvaluator;
|
|
1072
1257
|
private sentenceStructureEvaluator;
|
|
1258
|
+
private smkEvaluator;
|
|
1259
|
+
private conventionalityEvaluator;
|
|
1073
1260
|
private limit;
|
|
1074
1261
|
constructor(config: BaseEvaluatorConfig);
|
|
1075
1262
|
/**
|
|
1076
1263
|
* Evaluate text complexity for a given text and grade level
|
|
1077
1264
|
*
|
|
1078
|
-
* Runs vocabulary
|
|
1079
|
-
* If
|
|
1265
|
+
* Runs vocabulary, sentence structure, and SMK evaluations in parallel with concurrency control.
|
|
1266
|
+
* If all three sub-evaluators fail, throws an error. Otherwise returns a result map where
|
|
1080
1267
|
* failed sub-evaluators are represented as `{ error: Error }`.
|
|
1081
1268
|
*
|
|
1082
1269
|
* @param text - The text to evaluate
|
|
@@ -1139,4 +1326,4 @@ declare function addEngineeredFeatures(analysis: SentenceAnalysis): SentenceFeat
|
|
|
1139
1326
|
*/
|
|
1140
1327
|
declare function featuresToJSON(features: SentenceFeatures, decimals?: number, castToInt?: boolean): string;
|
|
1141
1328
|
|
|
1142
|
-
export { APIError, AuthenticationError, type BaseEvaluatorConfig, type ComplexityClassification, ComplexityClassificationSchema, ConfigurationError, type EvaluationError, type EvaluationMetadata, type EvaluationResult, EvaluatorError, type EvaluatorMetadata, GradeBand, GradeLevelAppropriatenessEvaluator, type GradeLevelAppropriatenessInternal, GradeLevelAppropriatenessSchema, type LLMProvider, type LLMRequest, type LLMResponse, type LogContext, LogLevel, type Logger, type Message, NetworkError, type ProviderConfig, RateLimitError, type ReadabilityMetrics, type SentenceAnalysis, SentenceAnalysisSchema, type SentenceFeatures, SentenceStructureEvaluator, type SentenceStructureInternal, type TelemetryOptions, TextComplexityEvaluator, TextComplexityLevel, type TextComplexityResult, type TextGenerationResponse, TimeoutError, ValidationError, VocabularyEvaluator, type VocabularyInternal, addEngineeredFeatures, calculateFleschKincaidGrade, calculateReadabilityMetrics, evaluateGradeLevelAppropriateness, evaluateSentenceStructure, evaluateTextComplexity, evaluateVocabulary, featuresToJSON };
|
|
1329
|
+
export { APIError, AuthenticationError, type BaseEvaluatorConfig, type ComplexityClassification, ComplexityClassificationSchema, ConfigurationError, ConventionalityEvaluator, type ConventionalityInternal, type EvaluationError, type EvaluationMetadata, type EvaluationResult, EvaluatorError, type EvaluatorMetadata, GradeBand, GradeLevelAppropriatenessEvaluator, type GradeLevelAppropriatenessInternal, GradeLevelAppropriatenessSchema, type LLMProvider, type LLMRequest, type LLMResponse, type LogContext, LogLevel, type Logger, type Message, NetworkError, type ProviderConfig, RateLimitError, type ReadabilityMetrics, type SentenceAnalysis, SentenceAnalysisSchema, type SentenceFeatures, SentenceStructureEvaluator, type SentenceStructureInternal, SmkEvaluator, type SmkInternal, type TelemetryOptions, TextComplexityEvaluator, TextComplexityLevel, type TextComplexityResult, type TextGenerationResponse, TimeoutError, ValidationError, VocabularyEvaluator, type VocabularyInternal, addEngineeredFeatures, calculateFleschKincaidGrade, calculateReadabilityMetrics, evaluateConventionality, evaluateGradeLevelAppropriateness, evaluateSentenceStructure, evaluateSmk, evaluateTextComplexity, evaluateVocabulary, featuresToJSON };
|