entity

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const WordTypeLemma = "lemma"

Variables

View Source
var (
	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")
	ErrUserWordNotFound    = errors.New("user word not found")
	ErrDuplicateUserWord   = errors.New("user word already exists")
	ErrInvalidUserWordText = errors.New("invalid user word text")
	ErrVocNotFound         = errors.New("word not found")
	ErrInvalidVocID        = errors.New("invalid word id")
	ErrInvalidVocText      = errors.New("invalid word text")
	ErrDuplicateWord       = errors.New("word already exists")
)

Domain errors for user entity and related aggregates.

Functions

This section is empty.

Types

type Language

type Language string

Language represents supported language codes using ISO-style abbreviations.

const (
	LanguageUnspecified Language = ""
	LanguageEnglish     Language = "en"
	LanguageChinese     Language = "zh"
	LanguageSpanish     Language = "es"
	LanguageFrench      Language = "fr"
	LanguageGerman      Language = "de"
	LanguageJapanese    Language = "ja"
	LanguageKorean      Language = "ko"
)

func NormalizeLanguage

func NormalizeLanguage(lang Language) Language

NormalizeLanguage ensures the language falls back to a supported value (defaults to English).

func ParseLanguage

func ParseLanguage(code string) Language

ParseLanguage converts an arbitrary string into a supported Language value.

func (Language) Code

func (l Language) Code() string

Code returns the lowercase language code (without defaulting).

func (Language) CodeOrDefault

func (l Language) CodeOrDefault() string

CodeOrDefault returns the language code, falling back to English when unspecified.

type MasteryBreakdown

type MasteryBreakdown struct {
	Listen    int32
	Read      int32
	Spell     int32
	Pronounce int32
	Overall   int32
}

MasteryBreakdown captures skill-specific mastery scores for a user word.

type Phrase

type Phrase struct {
	ID          int64            `json:"id"`
	Text        string           `json:"text"`
	Language    Language         `json:"language"`
	Definitions []WordDefinition `json:"definitions"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ReviewTiming

type ReviewTiming struct {
	LastReviewAt time.Time
	NextReviewAt time.Time
	IntervalDays int32
	FailCount    int32
}

ReviewTiming represents spaced repetition metadata for a user word.

type Sentence

type Sentence struct {
	Text      string `json:"text"`
	Source    int32  `json:"source"`
	SourceRef string `json:"source_ref,omitempty"`
}

Sentence captures a short contextual example recorded by the user.

type User

type User struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	Email     string    `json:"email"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

User represents a user entity in the domain

func (*User) Validate

func (u *User) Validate() error

Validate validates the user entity

type UserWord

type UserWord struct {
	ID         int64
	UserID     int64
	Word       string
	Language   Language
	Mastery    MasteryBreakdown
	Review     ReviewTiming
	QueryCount int64
	Notes      string
	Sentences  []Sentence
	Relations  []UserWordRelation
	CreatedBy  string
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

UserWord represents a user's personalised vocabulary entry.

func (*UserWord) Normalize

func (uw *UserWord) Normalize(now time.Time)

Normalize ensures defaults & constraints before persistence.

type UserWordRelation

type UserWordRelation struct {
	Word         string    `json:"word"`
	RelationType int32     `json:"relation_type"`
	Note         string    `json:"note,omitempty"`
	CreatedBy    string    `json:"created_by"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

UserWordRelation links a user word to another concept in their vocabulary graph.

type Word

type Word struct {
	ID          int64
	Text        string
	Language    Language
	WordType    string  // lemma, past, pp (past participle), ing (present participle), 3sg (third person singular), plural, comparative, superlative, variant, derived, other
	Lemma       *string // nil if this row itself is the lemma
	Phonetics   []WordPhonetic
	Definitions []WordDefinition // only populated for lemma rows
	Tags        []string
	Phrases     []Phrase
	Sentences   []Sentence
	Forms       []WordFormRef // if this is lemma: other forms; if not lemma: empty
	Relations   []WordRelation

	CreatedAt time.Time
	UpdatedAt time.Time
}

type WordDefinition

type WordDefinition struct {
	Pos      string   `json:"pos"`
	Text     string   `json:"text"`
	Language Language `json:"language"`
}

type WordFormRef

type WordFormRef struct {
	Text     string `json:"text"`
	WordType string `json:"word_type"`
}

type WordPhonetic

type WordPhonetic struct {
	IPA     string `json:"ipa"`
	Dialect string `json:"dialect,omitempty"`
}

type WordRelation

type WordRelation struct {
	Word         string `json:"word"`
	RelationType int32  `json:"relation_type"`
}

WordRelation models a connection to another dictionary entry.

Jump to

Keyboard shortcuts

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