ttmlSearchCore

package module
v0.0.0-...-08f93c0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RawLyrics = iota
	SpotifyLyrics
	QQLyrics
	NcmLyrics
	AmLyrics
)

并发读取解析ttml文件 读取方法

Variables

View Source
var LyricTypeMap = map[int]string{
	RawLyrics:     "RawLyrics",
	SpotifyLyrics: "SpotifyLyrics",
	QQLyrics:      "QQLyrics",
	NcmLyrics:     "NcmLyrics",
	AmLyrics:      "AmLyrics",
}
View Source
var LyricTypeMapZh = map[int]string{
	RawLyrics:     "原始歌词",
	SpotifyLyrics: "Spotify歌词",
	QQLyrics:      "QQ歌词",
	NcmLyrics:     "网易云歌词",
	AmLyrics:      "Apple music歌词",
}

Functions

func RunFileWorkers

func RunFileWorkers[T any](
	ctx context.Context,
	dir string,
	ext string,
	workerCount int,
	parseID func(fileName string) (string, error),
	handler WorkerFunc[T],
) <-chan T

RunFileWorkers 执行并发文件任务并返回结果通道

Types

type LyricIndex

type LyricIndex struct {
	ID          string   `json:"id"`
	Title       []string `json:"title"`
	Artist      []string `json:"artist"`
	Album       []string `json:"album"`
	LyricsCount int      `json:"lyricsCount"`
}

type LyricItem

type LyricItem struct {
	ID        string `json:"id"`
	SongID    string `json:"songId"`
	LineIndex int64  `json:"lineIndex"`
	Text      string `json:"text"`
	Trans     string `json:"trans,omitempty"`
	Roman     string `json:"roman,omitempty"`
	StartTime int64  `json:"startTime"`
	EndTime   int64  `json:"endTime"`
}

type LyricsClient

type LyricsClient struct {
	DocType  string
	Analyzer string
	// contains filtered or unexported fields
}

func NewLyrics

func NewLyrics(docType string, analyzer string, indexPath string) *LyricsClient

func (*LyricsClient) AddDoc

func (client *LyricsClient) AddDoc(id string, data any) error

AddDoc 添加文档

func (*LyricsClient) AddDocMapping

func (client *LyricsClient) AddDocMapping(docMapping *mapping.DocumentMapping, typestr string) *LyricsClient

func (*LyricsClient) AddDocs

func (client *LyricsClient) AddDocs(b *bleve.Batch) error

批量添加文档

func (*LyricsClient) BuildSearchFiled

func (client *LyricsClient) BuildSearchFiled(fields []LyricsSearchFiled) *bleve.SearchRequest

func (*LyricsClient) Close

func (client *LyricsClient) Close() error

func (*LyricsClient) CreateIndex

func (client *LyricsClient) CreateIndex() (bool, error)

func (*LyricsClient) CreateIndexMapping

func (client *LyricsClient) CreateIndexMapping() *LyricsClient

CreateIndexMapping 创建索引并将字段映射添加到索引

func (*LyricsClient) DeleteDoc

func (client *LyricsClient) DeleteDoc(id string) error

func (*LyricsClient) DocCount

func (client *LyricsClient) DocCount() int64

func (*LyricsClient) FindList

func (client *LyricsClient) FindList(request *bleve.SearchRequest, isHeigLight bool) ([]map[string]interface{}, *bleve.SearchResult, error)

core.go (请将此代码替换你的 FindList 函数)

func (*LyricsClient) FindOne

func (client *LyricsClient) FindOne(request *bleve.SearchRequest, isHeigLight bool) (map[string]interface{}, *bleve.SearchResult, error)

func (*LyricsClient) GetIndex

func (client *LyricsClient) GetIndex() bleve.Index

GetIndex

func (*LyricsClient) GetTermFrequency

func (client *LyricsClient) GetTermFrequency(field string, exclude []string, minFreq int) (map[string]int, error)

GetTermFrequency 返回指定字段中的词频统计表 参数:

field   - 要统计的字段名(如 "_all" 或 "lyrics.text")
exclude - 不需要的词列表
minFreq - 过滤掉出现次数低于此值的词

返回:map[term] = totalFrequency

func (*LyricsClient) UpdateDoc

func (client *LyricsClient) UpdateDoc(id string, data any) error

type LyricsSearchFiled

type LyricsSearchFiled struct {
	FieldName  string
	FieldValue string
}

type Task

type Task struct {
	ID   string
	Path string
}

Task 表示一个要执行的文件任务

type TermFreq

type TermFreq struct {
	Term  string
	Count int
}

func SortTermFrequency

func SortTermFrequency(freqMap map[string]int, descending bool) []TermFreq

type WorkerFunc

type WorkerFunc[T any] func(task Task) (T, error)

WorkerFunc 是处理单个任务的函数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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