relingo

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg *Config) *Client

func (*Client) GetUserInfo

func (c *Client) GetUserInfo() (*RespUserInfo, error)

func (*Client) GetVocabulary

func (c *Client) GetVocabulary(id, typ string) ([]string, error)

GetVocabulary 获取某个生词本的所有单词

func (*Client) GetVocabularyList

func (c *Client) GetVocabularyList() ([]VocabularyListItem, error)

GetVocabularyList 获取生词本列表

func (*Client) LockupDict

func (c *Client) LockupDict(word string) (*DictItem, error)

func (*Client) MasteredWords

func (c *Client) MasteredWords(id string) ([]string, error)

MasteredWords 获取已掌握的单词

func (*Client) Ready

func (c *Client) Ready() bool

func (*Client) SetToken

func (c *Client) SetToken(token string)

func (*Client) SubmitVocabulary

func (c *Client) SubmitVocabulary(words []string) error

SubmitVocabulary 标记单词已掌握

type Config added in v0.0.7

type Config struct {
	BaseURL string `toml:"baseUrl"`
	Token   string `toml:"token"`
}

func NewConfig added in v0.0.7

func NewConfig() *Config

type DictItem

type DictItem struct {
	Phonetic      []string      `json:"phonetic"`
	Variant       []string      `json:"variant"`
	WordFrequency int           `json:"wordFrequency"`
	Definition    string        `json:"definition"`
	Id            string        `json:"_id"`
	Source        string        `json:"source"`
	Lang          string        `json:"lang"`
	Translations  []Translation `json:"translations"`
	Display       string        `json:"display"`
	Mastered      bool          `json:"mastered"`
	Stared        bool          `json:"stared"`
	// Sentences  []interface{} `json:"sentences"`
	Revision   bool `json:"revision"`
	NeedRevise bool `json:"needRevise"`
}

func (*DictItem) GetMeanings

func (d *DictItem) GetMeanings() string

type LockupBody

type LockupBody struct {
	Text string `json:"text"`
	To   string `json:"to"`
}

type RD

type RespParseContent2

type RespParseContent2 struct {
	Words []Word `json:"words"`
}

type RespUserInfo

type RespUserInfo struct {
	Name   string `json:"name"`
	Avatar string `json:"avatar"`
	Email  string `json:"email"`
	Token  string `json:"token"`
}

type Response

type Response[Data RD] struct {
	Code    int         `json:"code"`
	Message interface{} `json:"message"`
	Data    Data        `json:"data"`
}

func NewResponse

func NewResponse[Data RD](data Data) *Response[Data]

type Translation

type Translation struct {
	Target string  `json:"target"`
	Pos    string  `json:"pos"`
	Score  float64 `json:"score"`
}

type Vocabulary

type Vocabulary struct {
	Id        string    `json:"_id"`
	Uid       string    `json:"uid"`
	Id1       string    `json:"id"`
	Name      string    `json:"name"`
	Type      string    `json:"type"`
	Words     []string  `json:"words"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt int64     `json:"updatedAt"`
}

type VocabularyBody

type VocabularyBody struct {
	Id    string   `json:"id"`
	Type  string   `json:"type"`
	Words []string `json:"words,omitempty"`
}

type VocabularyListItem

type VocabularyListItem struct {
	Count     int       `json:"count,omitempty"`
	Mastered  int       `json:"mastered,omitempty"`
	Id        string    `json:"_id,omitempty"`
	Uid       string    `json:"uid,omitempty"`
	Name      string    `json:"name"`
	Id1       string    `json:"id"`
	Type      string    `json:"type"`
	CreatedAt time.Time `json:"createdAt,omitempty"`
	UpdatedAt int64     `json:"updatedAt,omitempty"`
	Privilege string    `json:"privilege,omitempty"`
	Scope     string    `json:"scope,omitempty"`
	Level     string    `json:"level,omitempty"`
	Words     []string  `json:"words,omitempty"`
}

type Word

type Word struct {
	Id            string   `json:"_id"`
	Phonetic      []string `json:"phonetic"`
	Variant       []string `json:"variant"`
	WordFrequency int      `json:"wordFrequency"`
	Source        string   `json:"source"`
	Display       *string  `json:"display,omitempty"`
	Translations  []struct {
		Target string  `json:"target"`
		Pos    string  `json:"pos"`
		Score  float64 `json:"score"`
	} `json:"translations"`
	Lang      string `json:"lang"`
	Mastered  bool   `json:"mastered"`
	Stared    bool   `json:"stared"`
	Sentences []struct {
		Id        string `json:"_id"`
		Uid       string `json:"uid"`
		Word      string `json:"word"`
		Sentence  string `json:"sentence"`
		Url       string `json:"url"`
		CreatedAt int64  `json:"createdAt"`
		UpdatedAt int64  `json:"updatedAt"`
		Md5       string `json:"md5"`
	} `json:"sentences"`
	Revision   bool   `json:"revision"`
	NeedRevise bool   `json:"needRevise"`
	Scope      string `json:"scope,omitempty"`
}

func (*Word) String

func (w *Word) String() string

Jump to

Keyboard shortcuts

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