Documentation
¶
Index ¶
- Constants
- Variables
- func IsValidPartOfSpeech(pos PartOfSpeech) bool
- type CategoryStat
- type CompletenessBucket
- type DistillCache
- type FormType
- type Frequency
- type JobAction
- type JobStatus
- type Language
- type Lemma
- type LemmaForm
- type LemmaSnapshot
- type LemmaSnapshotData
- type LemmaSnapshotForm
- type LemmaSnapshotLexeme
- type LemmaSnapshotRelation
- type LemmaSnapshotSense
- type Lexeme
- type LexemeEntryType
- type LexemeSense
- type PartOfSpeech
- type Phonetic
- type PipelineJob
- type PipelinePhase
- type PipelineStage
- type QualityScore
- type RawEvidence
- type SemanticRelation
- type SenseExample
- type StageProgressSummary
- type StageStatus
- type WordCoverage
- type WordEntry
- type WordLanguageStats
- type WordStats
- type WordStatsFilter
- type WordStatsSummary
Constants ¶
const ( RelationSynonym = "SYNONYM" RelationAntonym = "ANTONYM" RelationHypernym = "HYPERNYM" // is-a (parent/superordinate) RelationHyponym = "HYPONYM" // is-a (child/subordinate) RelationAssociation = "ASSOCIATION" RelationCauseEffect = "CAUSE_EFFECT" RelationPartWhole = "PART_WHOLE" RelationDerivative = "DERIVATIVE" // WordNet-specific relations RelationMemberHolonym = "MEMBER_HOLONYM" // X is a member of Y RelationPartHolonym = "PART_HOLONYM" // X is a part of Y RelationMemberMeronym = "MEMBER_MERONYM" // Y has member X RelationPartMeronym = "PART_MERONYM" // Y has part X RelationAttribute = "ATTRIBUTE" // attribute relation RelationSimilar = "SIMILAR" // similar to RelationParticipleOf = "PARTICIPLE_OF" // verb participle form RelationDerivedFrom = "DERIVED_FROM" // derived/related form RelationCategory = "CATEGORY" // domain category RelationCategoryMember = "CATEGORY_MEMBER" // member of domain category )
RelationType constants for semantic relations between lexemes.
Variables ¶
var ( ErrInvalidInput = errors.New("invalid input") ErrUserNotFound = errors.New("user not found") ErrInvalidUserName = errors.New("invalid user name") ErrInvalidUserEmail = errors.New("invalid user email") ErrUserAlreadyExists = errors.New("user already exists") ErrInvalidUserID = errors.New("invalid user ID") ErrLearnedLexemeNotFound = errors.New("user lexeme not found") ErrDuplicateLearnedLexeme = errors.New("user lexeme already exists") ErrInvalidLearnedLexemeText = errors.New("invalid user lexeme text") ErrLexemeRequired = errors.New("lexeme id is required") ErrLexemeNotFound = errors.New("lexeme not found") ErrLanguageMismatch = errors.New("language mismatch") ErrInvalidLexemeID = errors.New("invalid lexeme id") ErrInvalidLexemeText = errors.New("invalid lexeme text") ErrDuplicateLexeme = errors.New("lexeme already exists") ErrWordNotFound = errors.New("word not found") ErrInvalidWordID = errors.New("invalid word id") ErrDuplicateWord = errors.New("word already exists") ErrPipelineJobNotFound = errors.New("pipeline job not found") )
Domain errors for user entity and related aggregates.
Functions ¶
func IsValidPartOfSpeech ¶ added in v0.8.0
func IsValidPartOfSpeech(pos PartOfSpeech) bool
IsValidPartOfSpeech reports whether pos is one of the canonical enum values.
Types ¶
type CategoryStat ¶ added in v0.3.0
CategoryStat summarizes how many lemmas fall under a specific category label.
type CompletenessBucket ¶ added in v0.3.0
CompletenessBucket is a histogram bucket describing how many words fall within a specific completeness score range.
type DistillCache ¶ added in v0.8.0
type DistillCache struct {
ID int64
ContextHash string // SHA256(Context + Prompt + Model)
Model string
PromptSummary string
Response map[string]any
TokenCount int32
CreatedAt time.Time
}
DistillCache stores cached LLM distillation responses.
type FormType ¶ added in v0.9.0
type FormType string
FormType enumerates normalized surface-form categories.
const ( FormTypeUnspecified FormType = "" FormTypeLemma FormType = "LEMMA" FormTypePlural FormType = "PLURAL" FormTypePast FormType = "PAST" FormTypePastParticiple FormType = "PAST_PARTICIPLE" FormTypePresentParticiple FormType = "PRESENT_PARTICIPLE" FormTypeThirdPersonSingular FormType = "THIRD_PERSON_SINGULAR" FormTypeComparative FormType = "COMPARATIVE" FormTypeSuperlative FormType = "SUPERLATIVE" FormTypeImperative FormType = "IMPERATIVE" FormTypeSubjunctive FormType = "SUBJUNCTIVE" FormTypeGerund FormType = "GERUND" FormTypeShortForm FormType = "SHORT_FORM" )
type Frequency ¶ added in v0.7.0
Frequency represents the frequency of a lemma in different corpora, used for usage-based ranking and filtering.
type JobAction ¶ added in v0.8.0
type JobAction string
JobAction represents an action to perform on a job.
func (JobAction) TargetStatus ¶ added in v0.8.0
TargetStatus returns the target status for a given action.
type JobStatus ¶ added in v0.8.0
type JobStatus string
JobStatus represents the state of a pipeline job.
func (JobStatus) IsTerminal ¶ added in v0.8.0
IsTerminal returns true if the job status is a terminal state.
func (JobStatus) ValidateTransition ¶ added in v0.8.0
ValidateTransition checks if the action can be performed on the current status.
type Language ¶
type Language string
Language represents supported language codes using ISO-style abbreviations.
func NormalizeLanguage ¶
NormalizeLanguage ensures the language falls back to a supported value (defaults to English).
func ParseLanguage ¶
ParseLanguage converts an arbitrary string into a supported Language value.
func (Language) CodeOrDefault ¶
CodeOrDefault returns the language code, falling back to English when unspecified.
type Lemma ¶ added in v0.3.0
type Lemma struct {
ID int64
Surface string
Normalized string
Variant string
Level string
Frequencies []Frequency
Syllables []string
Forms []*LemmaForm
CreatedAt time.Time
UpdatedAt time.Time
}
Lemma represents the canonical form of a word, along with its associated lexemes.
type LemmaForm ¶ added in v0.7.0
type LemmaForm struct {
ID int64
LemmaID int64
Surface string
Normalized string
FormType FormType
IsIrregular bool
Phonetics []Phonetic
Syllables []string
CreatedAt time.Time
UpdatedAt time.Time
}
LexemeForm captures a surfaced variant of a lexeme's lemma.
type LemmaSnapshot ¶ added in v0.8.0
type LemmaSnapshot struct {
ID int64
LemmaID int64
JobID *int64
Surface string
Normalized string
LookupTerms []string
Language string
IsLatest bool
Version int32
SchemaVersion int32
Payload LemmaSnapshotData
Quality QualityScore
LexemeCount int32
SenseCount int32
FormCount int32
RelationCount int32
ProviderCount int32
SynthesizedAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
LemmaSnapshot is the materialized, self-contained view of a lemma's knowledge.
type LemmaSnapshotData ¶ added in v0.8.0
type LemmaSnapshotData struct {
Lexemes []LemmaSnapshotLexeme `json:"lexemes,omitempty"`
Forms []LemmaSnapshotForm `json:"forms,omitempty"`
Categories []string `json:"categories,omitempty"`
Frequencies []Frequency `json:"frequencies,omitempty"`
Relations []LemmaSnapshotRelation `json:"relations,omitempty"`
}
LemmaSnapshotData is the self-contained materialized snapshot payload stored as JSON.
type LemmaSnapshotForm ¶ added in v0.8.0
type LemmaSnapshotForm struct {
Surface string `json:"surface"`
FormType string `json:"form_type"`
IsIrregular bool `json:"is_irregular,omitempty"`
Phonetics []Phonetic `json:"phonetics,omitempty"`
}
LemmaSnapshotForm represents an inflected form within a snapshot.
type LemmaSnapshotLexeme ¶ added in v0.8.0
type LemmaSnapshotLexeme struct {
ExternalID string `json:"external_id,omitempty"`
Language string `json:"language,omitempty"`
POS string `json:"pos"`
Senses []LemmaSnapshotSense `json:"senses,omitempty"`
}
LemmaSnapshotLexeme represents a POS-grouped lexeme entry within a snapshot.
type LemmaSnapshotRelation ¶ added in v0.8.0
type LemmaSnapshotRelation struct {
RelationType string `json:"relation_type"`
TargetTerm string `json:"target_term"`
TargetRef string `json:"target_ref,omitempty"`
Provider string `json:"provider"`
Strength float64 `json:"strength"`
SenseMapped bool `json:"sense_mapped,omitempty"`
TargetResolved bool `json:"target_resolved,omitempty"`
}
LemmaSnapshotRelation represents a semantic relation within a snapshot.
type LemmaSnapshotSense ¶ added in v0.8.0
type LemmaSnapshotSense struct {
Language string `json:"language"`
Gloss string `json:"gloss"`
Examples []string `json:"examples,omitempty"`
Provider string `json:"provider,omitempty"`
TrustWeight float64 `json:"trust_weight,omitempty"`
}
LemmaSnapshotSense represents a single definition/gloss within a snapshot.
type Lexeme ¶ added in v0.3.0
type Lexeme struct {
ID int64
LemmaID int64 // Foreign key to Lemma
ExternalID string // Wikidata Lexeme ID (e.g. "L123456")
Language Language
PartOfSpeech PartOfSpeech
EntryType LexemeEntryType
SenseGloss string
Senses []LexemeSense
Categories []string
Completeness int32
CreatedAt time.Time
UpdatedAt time.Time
}
Lexeme captures a semantic entry with its forms, senses, and metadata.
type LexemeEntryType ¶ added in v0.3.0
type LexemeEntryType string
LexemeEntryType distinguishes between top-level entry categories.
const ( LexemeEntryTypeUnspecified LexemeEntryType = "" LexemeEntryTypeWord LexemeEntryType = "WORD" LexemeEntryTypePhrase LexemeEntryType = "PHRASE" LexemeEntryTypeIdiom LexemeEntryType = "IDIOM" )
type LexemeSense ¶ added in v0.3.0
type LexemeSense struct {
Language Language `json:"language"`
Gloss string `json:"gloss"`
Examples []SenseExample `json:"examples,omitempty"`
}
LexemeSense models a language-specific gloss for a particular part of speech.
type PartOfSpeech ¶ added in v0.8.0
type PartOfSpeech string
PartOfSpeech is the canonical internal POS enum used across all data sources. Core set = UPOS, plus a small controlled extension set.
const ( PartOfSpeechUnspecified PartOfSpeech = "" PartOfSpeechNoun PartOfSpeech = "noun" PartOfSpeechVerb PartOfSpeech = "verb" PartOfSpeechAdjective PartOfSpeech = "adj" PartOfSpeechAdverb PartOfSpeech = "adv" PartOfSpeechPronoun PartOfSpeech = "pron" PartOfSpeechProperNoun PartOfSpeech = "propn" PartOfSpeechAdposition PartOfSpeech = "adp" PartOfSpeechDeterminer PartOfSpeech = "det" PartOfSpeechNumeral PartOfSpeech = "num" PartOfSpeechCCONJ PartOfSpeech = "cconj" PartOfSpeechSCONJ PartOfSpeech = "sconj" PartOfSpeechParticle PartOfSpeech = "part" PartOfSpeechInterjection PartOfSpeech = "intj" PartOfSpeechAuxiliary PartOfSpeech = "aux" PartOfSpeechSymbol PartOfSpeech = "sym" PartOfSpeechOther PartOfSpeech = "x" // Controlled extensions over UPOS. PartOfSpeechAbbreviation PartOfSpeech = "abbr" PartOfSpeechAffix PartOfSpeech = "affix" PartOfSpeechPrefix PartOfSpeech = "prefix" PartOfSpeechSuffix PartOfSpeech = "suffix" )
func ParsePartOfSpeech ¶ added in v0.8.0
func ParsePartOfSpeech(raw string) (PartOfSpeech, bool)
ParsePartOfSpeech parses a single POS token into the internal enum.
func (PartOfSpeech) Values ¶ added in v0.8.0
func (PartOfSpeech) Values() []string
Values implements Ent's EnumValues contract for schema GoType.
type PipelineJob ¶ added in v0.8.0
type PipelineJob struct {
ID int64
Status JobStatus
Name string
Language string
Tier int32
// Single-word job term.
Term string
ErrorMessage string
StartedAt *time.Time
CompletedAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
PipelineJob represents an async pipeline processing job.
type PipelinePhase ¶ added in v0.8.0
type PipelinePhase int32
PipelinePhase enumerates the five pipeline stages.
const ( PhaseDiscovery PipelinePhase = 1 PhaseLexical PipelinePhase = 2 PhaseRelational PipelinePhase = 3 PhaseIntellectual PipelinePhase = 4 PhaseSynthesis PipelinePhase = 5 )
func (PipelinePhase) Name ¶ added in v0.8.0
func (p PipelinePhase) Name() string
PhaseName returns a human-readable name for the phase.
type PipelineStage ¶ added in v0.8.0
type PipelineStage struct {
ID int64
JobID int64
LemmaID int64
Phase int32
Status StageStatus
Tier int32 // 1=Core, 2=Extended, 3=LongTail
Attempts int32
ErrorMessage string
StartedAt *time.Time
CompletedAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
PipelineStage tracks the execution state of a single pipeline phase for a job.
type QualityScore ¶ added in v0.8.0
type QualityScore struct {
Overall float64 `json:"overall"`
Completeness float64 `json:"completeness"`
Depth float64 `json:"depth"`
Density float64 `json:"density"`
Validity float64 `json:"validity"`
}
QualityScore captures multi-dimensional quality metrics for a lemma snapshot.
type RawEvidence ¶ added in v0.8.0
type RawEvidence struct {
ID int64
LemmaID int64
Provider string // "wikidata", "wordnet", "ecdict", "conceptnet", "llm", "manual"
Phase int32 // 1-5
Content map[string]any
SchemaVersion string
FetchedAt time.Time
CreatedAt time.Time
}
RawEvidence stores a raw response envelope from an external data provider.
type SemanticRelation ¶ added in v0.8.0
type SemanticRelation struct {
ID int64
SourceLexemeID int64 // DB foreign key, set by persistence layer
SourceExternalID string // Wikidata ExternalID, set by processors
TargetLexemeID *int64 // nil = unresolved
TargetRef string // stable target URI, e.g. wikidata://lexeme/L123
TargetTerm string // always set, display text
RelationType string
Provider string // "wordnet", "conceptnet", "ecdict", "llm", "manual"
Strength float64 // 0.0-1.0
SenseMapped bool
CreatedAt time.Time
UpdatedAt time.Time
}
SemanticRelation links two lexemes with a typed semantic relationship.
type SenseExample ¶ added in v0.3.0
type SenseExample struct {
Text string `json:"text"`
Translation string `json:"translation,omitempty"`
}
SenseExample illustrates a particular sense.
type StageProgressSummary ¶ added in v0.8.0
type StageProgressSummary struct {
Total int
Completed int
Failed int
Skipped int
Running int
Pending int
}
StageProgressSummary aggregates stage statuses for display.
func ComputeStageProgress ¶ added in v0.8.0
func ComputeStageProgress(stages []*PipelineStage) *StageProgressSummary
ComputeStageProgress computes a StageProgressSummary from a list of stages.
func (*StageProgressSummary) String ¶ added in v0.8.0
func (s *StageProgressSummary) String() string
String returns a compact representation, e.g. "5/5" or "3/5 (skip:1, fail:1)".
type StageStatus ¶ added in v0.8.0
type StageStatus string
StageStatus represents the state of a pipeline stage.
const ( StageStatusPending StageStatus = "PENDING" StageStatusRunning StageStatus = "RUNNING" StageStatusCompleted StageStatus = "COMPLETED" StageStatusFailed StageStatus = "FAILED" StageStatusSkipped StageStatus = "SKIPPED" )
type WordCoverage ¶ added in v0.3.0
WordCoverage captures the percentage of words that carry a specific attribute.
type WordEntry ¶ added in v0.3.0
type WordEntry struct {
QueriedTerm string
Lemma *Lemma // The lemma that was found (contains forms and lexeme reference)
Lexemies []Lexeme // Associated lexemes with semantic information
}
WordEntry carries lookup context for a lemma and the queried surface term.
type WordLanguageStats ¶ added in v0.3.0
type WordLanguageStats struct {
Language Language
WordCount int64
LexemeCount int64
AvgCompleteness float64
PhoneticCoverage float64
DefinitionCoverage float64
FormCoverage float64
CategoryCoverage float64
}
WordLanguageStats exposes per-language richness and completeness data.
type WordStats ¶ added in v0.3.0
type WordStats struct {
Summary WordStatsSummary
Coverage WordCoverage
Languages []WordLanguageStats
TopCategories []CategoryStat
Completeness []CompletenessBucket
}
WordStats bundles the aggregated data needed for the overview dashboard.
type WordStatsFilter ¶ added in v0.3.0
type WordStatsFilter struct {
Languages []Language
}
WordStatsFilter scopes statistics to specific languages.