semantic

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 4 Imported by: 0

README

Semantic Analyzer Cheat Sheet

This helper stays lightweight on purpose: no external NLP, just lexical heuristics that are fast enough to run for every CLI query.

Flow Example

Input query:

urgent: api gateway errors after deploy

  1. Normalize & tokenize – lowercase and split into words.
  2. Intent scoring – sum weights from IntentSignals:
    • error adds 1.0 to the troubleshoot bucket.
    • Highest score wins, so intent.Primary = "troubleshoot" and Confidence = score / len(words).
  3. Service mapping – scan ServiceMapping for keyword hits:
    • api / gatewayintent.TargetServices = ["api_gateway"].
  4. Urgency – accumulate weights from UrgencyKeywords (urgent, error) and bucket (critical/high/medium/low).
  5. Time frame – first match in TimeFrameWords (default recent if none).
  6. Data types – explicit hints (logs, metrics, status). If absent, fall back to defaults per intent (troubleshoot → logs, metrics, status).

The resulting model.QueryIntent gets stored in agentCtx.GatheredData["semantic_analysis"], giving planners enough structure to choose which collectors to run.

Documentation

Overview

Package semantic provides lightweight NLP intent analysis for user queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer

type Analyzer struct {
	KeywordWeights  KeywordWeights
	ContextPatterns ContextPatterns
	ServiceMapping  ServiceMapping
	IntentSignals   IntentSignals
	UrgencyKeywords UrgencyKeywords
	TimeFrameWords  TimeFrameWords
}

Analyzer keeps lightweight lexical resources used during semantic classification.

func NewAnalyzer

func NewAnalyzer() *Analyzer

func (*Analyzer) AnalyzeQuery

func (sa *Analyzer) AnalyzeQuery(query string) model.QueryIntent

AnalyzeQuery performs a purely lexical pass that classifies the user's question without calling external NLP services. It scores intent by summing word weights, infers urgency and timeframe from keyword buckets, tags cloud services via the mapping table, and fills in likely data types so downstream planners can quickly decide which collectors to run.

type ContextPatterns

type ContextPatterns map[string][]string

ContextPatterns groups workflow-specific hint words (monitoring vs troubleshooting, etc.).

type IntentSignals

type IntentSignals map[string]map[string]float64

IntentSignals describes per-intent weights used during scoring.

type KeywordWeights

type KeywordWeights map[string]float64

KeywordWeights biases confidence toward terms that historically correlate with outages.

type ServiceMapping

type ServiceMapping map[string][]string

ServiceMapping tags AWS services based on keywords embedded in the query.

type TimeFrameWords

type TimeFrameWords map[string]string

TimeFrameWords maps colloquial phrases to time windows like historical or recent.

type UrgencyKeywords

type UrgencyKeywords map[string]float64

UrgencyKeywords help translate user language into urgency buckets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL