Class ComplexityAnalyzer
- Namespace
- AiDotNet.PromptEngineering.Analysis
- Assembly
- AiDotNet.dll
Analyzer that focuses on measuring prompt complexity and structure.
public class ComplexityAnalyzer : PromptAnalyzerBase, IPromptAnalyzer
- Inheritance
-
ComplexityAnalyzer
- Implements
- Inherited Members
Remarks
This analyzer provides detailed complexity metrics including readability scores, structural analysis, and recommendations for simplification.
For Beginners: Measures how complicated your prompt is.
Example:
var analyzer = new ComplexityAnalyzer();
var metrics = analyzer.Analyze(complexPrompt);
Console.WriteLine($"Complexity: {metrics.ComplexityScore:P0}");
// 0% = very simple, 100% = very complex
// Access detailed breakdown:
if (metrics is ExtendedPromptMetrics extended)
{
Console.WriteLine($"Readability: {extended.ReadabilityScore:F1}");
Console.WriteLine($"Nesting depth: {extended.NestingDepth}");
}
High complexity might mean:
- Difficult for AI to understand
- Higher chance of misinterpretation
- May need simplification
Constructors
ComplexityAnalyzer(Func<string, int>?)
Initializes a new instance of the ComplexityAnalyzer class.
public ComplexityAnalyzer(Func<string, int>? tokenCounter = null)
Parameters
Methods
CustomValidation(string, ValidationOptions)
Adds custom validation for complexity-related issues.
protected override IEnumerable<PromptIssue> CustomValidation(string prompt, ValidationOptions options)
Parameters
promptstringoptionsValidationOptions
Returns
EnhanceMetrics(string, PromptMetrics)
Adds detailed complexity metrics to the analysis.
protected override void EnhanceMetrics(string prompt, PromptMetrics metrics)
Parameters
promptstringmetricsPromptMetrics