Documentation
¶
Index ¶
- func CreateSubtitleIndex(folder, lang string) (bleve.Index, error)
- func OpenTranscriptionIndex(folder, lang string) (bleve.Index, error)
- func TextQuery(query string, index bleve.Index) (*bleve.SearchResult, error)
- type ScoredSegment
- type SearchResult
- type SearchResultSequence
- type SegmentHit
- type Transcription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateSubtitleIndex ¶
CreateSubtitleIndex opens, parses and indexes the subtitles file in the given folder and the given language. The created index is saved inside the folder.
func OpenTranscriptionIndex ¶
OpenTranscriptionIndex opens a stored subtitle index, such as the one created by CreateSubtitleIndex.
Types ¶
type ScoredSegment ¶
type ScoredSegment struct { SegmentHit Score float64 `json:"score"` ID string `json:"id"` }
ScoredSegment is a SegmentHit with its score and its transcription ID.
type SearchResult ¶
type SearchResult struct { ID string Score float64 Segments []SegmentHit // Segments that matched with the search query. }
SearchResult represents a transcription file that matched with a search query.
type SearchResultSequence ¶
type SearchResultSequence []SearchResult
SearchResultSequence represents a sequence of transcription files that matched with a search query.
func AssembleSearchResults ¶
func AssembleSearchResults(bleveResults *bleve.SearchResult) (SearchResultSequence, error)
AssembleSearchResults builds transcription search results with timestamp information using raw bleve search results.
func (SearchResultSequence) ScoredSegments ¶
func (srs SearchResultSequence) ScoredSegments() []ScoredSegment
ScoredSegments flattens a search results hierarchy by returning the scored segments, sorted by score.
type SegmentHit ¶
type SegmentHit struct { StartTime time.Duration `json:"start_time"` EndTime time.Duration `json:"end_time"` SortedTerms []string `json:"sorted_terms"` // Terms in the segment that matched with the search query, sorted in increasing order. }
SegmentHit represents a transcription segment that matched with a search query.
func (SegmentHit) NDistinctTerms ¶
func (sh SegmentHit) NDistinctTerms() int
NDistinctTerms returns the number of distinct terms in the segment that matched with the search query.
type Transcription ¶
Transcription stores the whole transcription text, as well as all the segments in a manner usable by bleve. The reason for using a slice of float64 rather then a slice of transcriptionSegment is that bleve does not support time.Duration or int, only float64.
func ParseSubtitleFile ¶
func ParseSubtitleFile(filename string) (*Transcription, error)
ParseSubtitleFile transforms a subtitle file into a Transcription usable by bleve.
func (Transcription) BleveType ¶
func (Transcription) BleveType() string
BleveType tells bleve what type of document a Transcription is.