entity

package
v0.0.0-...-fb119ec Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Positive    Degree = 0
	Comparative        = 1
	Superlative        = 2
)
View Source
const (
	Strong Declension = 0
	Weak              = 1
	Mixed             = 2
)
View Source
const (
	Der Article = "r"
	Die         = "e"
	Das         = "s"
)
View Source
const (
	ReflexiveWithout   Reflexive = ""
	ReflexiveAcusative           = "A"
	ReflexiveDative              = "D"
)
View Source
const (
	CaseNominative Case = "N"
	CaseAcusative       = "A"
	CaseDative          = "D"
	CaseGenitive        = "G"
)
View Source
const (
	S1 PersonalPronoun = "S1"
	S2                 = "S2"
	S3                 = "S3"
	P1                 = "P1"
	P2                 = "P2"
	P3                 = "P3"
)
View Source
const (
	Present        Tense = "Present"
	Preterite            = "Preterite"
	PastParticiple       = "Past Participle"
)

Variables

View Source
var (
	// Auxiliary:
	// ^                      -- match beginning of string
	//  ([sh])                -- match first auxiliary notion <-- s: sein, h: haben
	//        (/([hs]))?      -- match optional second auxiliary notion, followin a / sign
	//                  $     -- match end of string
	AuxiliaryRegexp = regexp.MustCompile("^([sh])(/([hs]))?$")

	// Argument:
	// ^                                  -- match beginning of string
	//  ([^(]*)                           -- match any string that is not a open parantheses character
	//          ?                         -- match optional space character
	//           (                        -- start of parantheses matching
	//            [(]                       -- match open parantheses character
	//               ([NADG])               -- match a case notion character  <-- N: nominative, A: acusative, D: dative, G: genitive
	//                       [)]            -- match close parantheses character
	//                          )?          -- end of parantheses matching
	//                             *      -- match optional spaces
	//                              $     -- match end of string
	ArgumentRegexp = regexp.MustCompile("^([^(]*) ?([(]([NADG])[)])? *$")

	// Verb:
	// ^                                                 -- match beginning of string
	//  ([A-ZÄÖÜßa-zäöü, ]+)                             -- match verb
	//                     ([A-ZÄÖÜßa-zäöü+() ]*)?       -- match extension(s), separated by plus signs
	//                                            $      -- match end of string
	VerbRegexp = regexp.MustCompile("^([A-ZÄÖÜßa-zäöü|,/ -]+)([A-ZÄÖÜßa-zäöü+()/ -]*)?$")
)
View Source
var (
	// Meaning:
	// ^                                -- match beginning of string
	//  ([^(]*)                         -- match any string that is not a open parantheses character
	//          ?                       -- match optional space character
	//           (                      -- start of parantheses matching
	//            [(]                     -- match open parantheses character
	//               ([^)]*)              -- match parantheses content
	//                      [)]           -- match close parantheses character
	//                         )?         -- end of parantheses matching
	//                           *      -- match optional spaces
	//                            $     -- match end of string
	MeaningRegexp = regexp.MustCompile("^([^(]*) ?([(]([^)]*)[)])? *$")

	// German Word:
	// ^                           -- match beginning of string
	//  [a-zA-ZäÄöÖüÜß,.() ]*      -- German words can only contain German letters, dots, parantheses and spaces
	//                       $     -- match end of string
	GermanRegexp = regexp.MustCompile("^[a-zA-ZäÄöÖüÜß,.() ]*$")
)
View Source
var (
	// Adjective:
	// ^                                                       -- match beginning of string
	//  ([a-zäöüß]+)                                           -- match adjective
	//              (,([a-zäöüß~⍨-]*))?                        -- match optional comparative, can be an extension only starting with a ⍨, ~
	//                                 (,([a-zäöüß~⍨-]*))?     -- match optional superlative, can be an extension
	//                                                    $    -- match end of string
	AdjectiveRegexp = regexp.MustCompile("^([a-zäöüß]+)(,([a-zäöüß~⍨-]*))?(,([a-zäöüß~⍨-]*))?$")
)
View Source
var (
	// Article:
	// ^                      -- match beginning of string
	//  ([res])               -- match first article notion <-- r: der, e: die, s: das
	//         (/([res]))?    -- match optional second article notion, following a / sign
	//                    $   -- match end of string
	ArticleRegexp = regexp.MustCompile("^([res])(/([res]))?$")
)
View Source
var (
	// Noun:
	// ^                                                                                           -- match beginning of string
	//  ([A-ZÄÖÜ][A-ZÄÖÜßa-zäöü ]+)                                                                -- match noun in singular, must start with a capital
	//                             ,                                                               -- match a comma
	//                              ([A-ZÄÖÜa-zäöü~⍨ -]*)                                          -- match plural part, can be an extension only starting with a ⍨, ~
	//                                                     (,([A-ZÄÖÜßa-zäöü~⍨ ]*()?               -- match optional genitive, can be an extension
	//                                                                              ([(]pl[)])     -- match plural only note
	//                                                                                        $    -- match end of string
	NounRegexp = regexp.MustCompile("^([A-ZÄÖÜ][A-ZÄÖÜßa-zäöü -]+),([A-ZÄÖÜa-zäöü~⍨/ -]*)(,([A-ZÄÖÜßa-zäöü~⍨/ -]*))?([(]pl[)])?$")
)

Functions

func DefiniteArticle

func DefiniteArticle(word string, nounArticle Article, isPlural bool, nounCase Case) string

func IndefiniteArticle

func IndefiniteArticle(word string, nounArticle Article, isPlural bool, nounCase Case) string

func NewVerbP1

func NewVerbP1(german string) string

Types

type Adjective

type Adjective struct {
	DefaultWord `bson:"word" json:"word,omitempty"`
	Comparative []string      `bson:"comparative" json:"comparative,omitempty"`
	Superlative []string      `bson:"superlative" json:"superlative,omitempty"`
	Id          bson.ObjectId `bson:"_id,omitempty" json:"_id,omitempty"`
}

func NewAdjective

func NewAdjective(german, english, third, user, learned, score, tags string) *Adjective

func (*Adjective) Decline

func (a *Adjective) Decline(
	degree Degree,
	declension Declension,
	nounArticle Article,
	isPlural bool,
	nounCase Case,
) []string

func (*Adjective) GetComparative

func (a *Adjective) GetComparative() []string

func (*Adjective) GetComparativeString

func (a *Adjective) GetComparativeString(maxCount int) string

func (*Adjective) GetId

func (a *Adjective) GetId() bson.ObjectId

func (*Adjective) GetScores

func (a *Adjective) GetScores() []*general.Score

func (*Adjective) GetSuperlative

func (a *Adjective) GetSuperlative() []string

func (*Adjective) GetSuperlativeString

func (a *Adjective) GetSuperlativeString(maxCount int) string

func (*Adjective) SetId

func (a *Adjective) SetId(id bson.ObjectId)

type Any

type Any struct {
	DefaultWord `bson:"word" json:"word,omitempty"`
	Id          bson.ObjectId `bson:"_id,omitempty" json:"_id,omitempty"`
}

func NewAny

func NewAny(german, english, third, category, user, learned, score, tags string, errors []string) *Any

func (*Any) GetId

func (a *Any) GetId() bson.ObjectId

func (*Any) GetScores

func (a *Any) GetScores() []*general.Score

func (*Any) SetId

func (a *Any) SetId(id bson.ObjectId)

type Argument

type Argument struct {
	Preposition string `bson:"prep" json:"prep,omitempty"`
	Case        Case   `bson:"case" json:"case,omitempty"`
}

func NewArgument

func NewArgument(word string) Argument

func NewArguments

func NewArguments(allArguments string) []Argument

type Article

type Article string

type Auxiliary

type Auxiliary string
const (
	Sein  Auxiliary = "s"
	Haben           = "h"
)

func NewAuxiliary

func NewAuxiliary(auxiliaries []string) []Auxiliary

type Case

type Case string

type Declension

type Declension int

type DefaultWord

type DefaultWord struct {
	German   string           `bson:"german" json:"german,omitempty"`
	English  []Meaning        `bson:"english" json:"english,omitempty"`
	Third    []Meaning        `bson:"third" json:"third,omitempty"`
	Category string           `bson:"category" json:"category,omitempty"`
	User     string           `bson:"user" json:"user,omitempty"`
	Learned  time.Time        `bson:"learned" json:"learned,omitempty"`
	Score    int              `bson:"score" json:"score,omitempty"`
	Tags     []string         `bson:"tags" json:"tags,omitempty"`
	Errors   []string         `bson:"errors" json:"errors,omitempty"`
	Scores   []*general.Score `bson:"scores" json:"scores,omitempty"`
}

func NewDefaultWord

func NewDefaultWord(german, english, third, category, user, learned, score, tags string, errors []string) DefaultWord

func (*DefaultWord) AddScore

func (w *DefaultWord) AddScore(score *general.Score)

func (*DefaultWord) GetCategory

func (w *DefaultWord) GetCategory() string

func (*DefaultWord) GetEnglish

func (w *DefaultWord) GetEnglish() []Meaning

func (*DefaultWord) GetErrors

func (w *DefaultWord) GetErrors() []string

func (*DefaultWord) GetGerman

func (w *DefaultWord) GetGerman() string

func (*DefaultWord) GetId

func (w *DefaultWord) GetId() bson.ObjectId

func (*DefaultWord) GetLearned

func (w *DefaultWord) GetLearned() time.Time

func (*DefaultWord) GetScore

func (w *DefaultWord) GetScore() int

func (*DefaultWord) GetScores

func (w *DefaultWord) GetScores() []*general.Score

func (*DefaultWord) GetThird

func (w *DefaultWord) GetThird() []Meaning

func (*DefaultWord) GetUser

func (w *DefaultWord) GetUser() string

func (*DefaultWord) NewScore

func (w *DefaultWord) NewScore(result int)

func (*DefaultWord) SetId

func (w *DefaultWord) SetId(id bson.ObjectId)

type Degree

type Degree int

type Meaning

type Meaning struct {
	Main        string `bson:"main" json:"main,omitempty"`
	Parantheses string `bson:"parantheses" json:"parantheses,omitempty"`
}

func NewMeanings

func NewMeanings(allMeanings string, errors []string) ([]Meaning, []string)

type Noun

type Noun struct {
	DefaultWord  `bson:"word" json:"word,omitempty"`
	Articles     []Article     `bson:"article" json:"article,omitempty"`
	Plural       []string      `bson:"plural" json:"plural,omitempty"`
	Genitive     []string      `bson:"genitive" json:"genitive,omitempty"`
	IsPluralOnly bool          `bson:"plural_only" json:"plural_only,omitempty"`
	Id           bson.ObjectId `bson:"_id,omitempty" json:"_id,omitempty"`
}

func NewNoun

func NewNoun(articles, german, english, third, user, learned, score, tags string) *Noun

func (*Noun) Decline

func (n *Noun) Decline(
	isPlural bool,
	nounCase Case,
) []string

http://en.wikipedia.org/wiki/German_nouns#Declension_for_case

func (*Noun) GetGenitives

func (n *Noun) GetGenitives() []string

func (*Noun) GetGenitivesString

func (n *Noun) GetGenitivesString(maxCount int) string

func (*Noun) GetId

func (n *Noun) GetId() bson.ObjectId

func (*Noun) GetPlurals

func (n *Noun) GetPlurals() []string

func (*Noun) GetPluralsString

func (n *Noun) GetPluralsString(maxCount int) string

func (*Noun) GetScores

func (n *Noun) GetScores() []*general.Score

func (*Noun) IsMixed

func (n *Noun) IsMixed() bool

func (*Noun) SetId

func (n *Noun) SetId(id bson.ObjectId)

type PersonalPronoun

type PersonalPronoun string

type Prefix

type Prefix struct {
	Prefix    string `bson:"prefix" json:"prefix,omitempty"`
	Separable bool   `bson:"separable" json:"separable,omitempty"`
}

func NewPrefix

func NewPrefix(german string) Prefix

type Reflexive

type Reflexive string

type Tense

type Tense string

type Verb

type Verb struct {
	DefaultWord    `bson:"word" json:"word,omitempty"`
	Auxiliary      []Auxiliary   `bson:"auxiliary" json:"auxiliary,omitempty"`
	Prefix         Prefix        `bson:"prefix" json:"prefix,omitempty"`
	Noun           string        `bson:"noun" json:"noun,omitempty"`
	Adjective      string        `bson:"adjective" json:"adjective,omitempty"`
	PastParticiple []string      `bson:"pastParticiple" json:"pastParticiple,omitempty"`
	Preterite      []string      `bson:"preterite" json:"preterite,omitempty"`
	S1             []string      `bson:"s1" json:"s1,omitempty"`
	S2             []string      `bson:"s2" json:"s2,omitempty"`
	S3             []string      `bson:"s3" json:"s3,omitempty"`
	P1             []string      `bson:"p1" json:"p1,omitempty"`
	P2             []string      `bson:"p2" json:"p2,omitempty"`
	P3             []string      `bson:"p3" json:"p3,omitempty"`
	Reflexive      Reflexive     `bson:"reflexive" json:"reflexive,omitempty"`
	Arguments      []Argument    `bson:"arguments" json:"arguments,omitempty"`
	Id             bson.ObjectId `bson:"_id,omitempty" json:"_id,omitempty"`
}

func NewVerb

func NewVerb(auxiliary, german, english, third, user, learned, score, tags string) *Verb

func (*Verb) GetId

func (v *Verb) GetId() bson.ObjectId

func (*Verb) GetPresentP1

func (v *Verb) GetPresentP1() []string

func (*Verb) GetPresentP2

func (v *Verb) GetPresentP2() []string

func (*Verb) GetPresentP3

func (v *Verb) GetPresentP3() []string

func (*Verb) GetPresentS1

func (v *Verb) GetPresentS1() []string

func (*Verb) GetPresentS2

func (v *Verb) GetPresentS2() []string

func (*Verb) GetPresentS3

func (v *Verb) GetPresentS3() []string

func (*Verb) GetPreteriteP1

func (v *Verb) GetPreteriteP1() []string

func (*Verb) GetPreteriteP2

func (v *Verb) GetPreteriteP2() []string

func (*Verb) GetPreteriteP3

func (v *Verb) GetPreteriteP3() []string

func (*Verb) GetPreteriteS1

func (v *Verb) GetPreteriteS1() []string

func (*Verb) GetPreteriteS2

func (v *Verb) GetPreteriteS2() []string

func (*Verb) GetPreteriteS3

func (v *Verb) GetPreteriteS3() []string

func (*Verb) GetScores

func (v *Verb) GetScores() []*general.Score

func (*Verb) GetSeparated

func (v *Verb) GetSeparated(pp PersonalPronoun, tense Tense) [][2]string

func (*Verb) GetVerb

func (v *Verb) GetVerb(pp PersonalPronoun, tense Tense) []string

func (*Verb) GetVerbPresent

func (v *Verb) GetVerbPresent(pp PersonalPronoun) []string

func (*Verb) GetVerbPreterite

func (v *Verb) GetVerbPreterite(pp PersonalPronoun) []string

func (*Verb) SetId

func (v *Verb) SetId(id bson.ObjectId)

type Word

type Word interface {
	GetId() bson.ObjectId
	SetId(bson.ObjectId)
	GetGerman() string
	GetEnglish() []Meaning
	GetThird() []Meaning
	GetCategory() string
	GetUser() string
	GetScore() int
	GetLearned() time.Time
	GetErrors() []string
	GetScores() []*general.Score
	AddScore(score *general.Score)
	NewScore(result int)
}

Jump to

Keyboard shortcuts

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