db

package
v1.1.15 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BookChapterMap = map[string]int{
	`GEN`: 50,
	`EXO`: 40,
	`LEV`: 27,
	`NUM`: 36,
	`DEU`: 34,
	`JOS`: 24,
	`JDG`: 21,
	`RUT`: 4,
	`1SA`: 31,
	`2SA`: 24,
	`1KI`: 22,
	`2KI`: 25,
	`1CH`: 29,
	`2CH`: 36,
	`EZR`: 10,
	`NEH`: 13,
	`EST`: 10,
	`JOB`: 42,
	`PSA`: 150,
	`PRO`: 31,
	`ECC`: 12,
	`SNG`: 8,
	`ISA`: 66,
	`JER`: 52,
	`LAM`: 5,
	`EZK`: 48,
	`DAN`: 12,
	`HOS`: 14,
	`JOL`: 3,
	`AMO`: 9,
	`OBA`: 1,
	`JON`: 4,
	`MIC`: 7,
	`NAM`: 3,
	`HAB`: 3,
	`ZEP`: 3,
	`HAG`: 2,
	`ZEC`: 14,
	`MAL`: 4,
	`COV`: 4,
	`MAT`: 28,
	`MRK`: 16,
	`LUK`: 24,
	`JHN`: 21,
	`ACT`: 28,
	`ROM`: 16,
	`1CO`: 16,
	`2CO`: 13,
	`GAL`: 6,
	`EPH`: 6,
	`PHP`: 4,
	`COL`: 4,
	`1TH`: 5,
	`2TH`: 3,
	`1TI`: 6,
	`2TI`: 4,
	`TIT`: 3,
	`PHM`: 1,
	`HEB`: 13,
	`JAS`: 5,
	`1PE`: 5,
	`2PE`: 3,
	`1JN`: 5,
	`2JN`: 1,
	`3JN`: 1,
	`JUD`: 1,
	`REV`: 22,
}
View Source
var BookNT = []string{`MAT`, `MRK`, `LUK`, `JHN`, `ACT`, `ROM`, `1CO`, `2CO`, `GAL`, `EPH`, `PHP`, `COL`,
	`1TH`, `2TH`, `1TI`, `2TI`, `TIT`, `PHM`, `HEB`, `JAS`, `1PE`, `2PE`, `1JN`, `2JN`, `3JN`, `JUD`, `REV`}
View Source
var BookOT = []string{`GEN`, `EXO`, `LEV`, `NUM`, `DEU`, `JOS`, `JDG`, `RUT`, `1SA`, `2SA`, `1KI`, `2KI`,
	`1CH`, `2CH`, `EZR`, `NEH`, `EST`, `JOB`, `PSA`, `PRO`, `ECC`, `SNG`, `ISA`, `JER`, `LAM`, `EZK`, `DAN`,
	`HOS`, `JOL`, `AMO`, `OBA`, `JON`, `MIC`, `NAM`, `HAB`, `ZEP`, `HAG`, `ZEC`, `MAL`, `COV`}
View Source
var BookSeqMap = map[string]int{}/* 117 elements not displayed */

Functions

func DatabaseExists

func DatabaseExists(username string, project string) bool

func DestroyDatabase

func DestroyDatabase(database string)

DestroyDatabase should only be used by testing

func GetDBPath

func GetDBPath(database string) string

GetDBPath is not correct with user/project database names

func RequestedBooks

func RequestedBooks(testament request.Testament) []string

func Testament

func Testament(bookId string) string

func USFMBookId

func USFMBookId(ctx context.Context, bookName string) string

Types

type Audio

type Audio struct {
	WordId          int64          `json:"word_id,omitempty"` // Used only for Word table
	ScriptId        int64          `json:"script_id"`
	BookId          string         `json:"book_id"`
	ChapterNum      int            `json:"chapter_num"`
	ChapterEnd      int            `json:"chapter_end"`
	VerseStr        string         `json:"verse_str"`
	VerseEnd        string         `json:"verse_end"`
	VerseSeq        int            `json:"verse_seq"`
	WordSeq         int            `json:"word_seq"` // Used by Words, not Verses
	BeginTS         float64        `json:"begin_ts"`
	EndTS           float64        `json:"end_ts"`
	FAScore         float64        `json:"fa_score"`
	Uroman          string         `json:"uroman"` // Is this useful?
	Text            string         `json:"text"`
	Chars           []generic.Char `json:"-"`
	AudioFile       string         `json:"audio_file"`
	ScriptBeginTS   float64        `json:"script_begin_ts"` // Contains script TS when it is a word record
	ScriptEndTS     float64        `json:"script_end_ts"`   // Contains script TS when it is a word record
	ScriptFAScore   float64        `json:"script_fa_score"` // Contains script score when it is a word record
	AudioChapterWav string         `json:"-"`               // Transient
	AudioVerseWav   string         `json:"-"`               // Transient
}

type DBAdapter

type DBAdapter struct {
	Ctx          context.Context
	User         string
	Project      string
	Database     string
	DatabasePath string
	DB           *sql.DB
}

func NewDBAdapter

func NewDBAdapter(ctx context.Context, database string) DBAdapter

NewDBAdapter should be used for :memory: database and test.

func NewerDBAdapter

func NewerDBAdapter(ctx context.Context, isNew bool, user string, project string) (DBAdapter, *log.Status)

NewerDBAdapter should be used for production

func (*DBAdapter) CheckScriptInserts

func (d *DBAdapter) CheckScriptInserts(records []Script) *log.Status

func (*DBAdapter) Close

func (d *DBAdapter) Close()

func (*DBAdapter) CopyDatabase

func (d *DBAdapter) CopyDatabase(suffix string) (DBAdapter, *log.Status)

CopyDatabase copies a database, closes it and return a connection to the copy

func (*DBAdapter) CountIdentRows

func (d *DBAdapter) CountIdentRows() (int, *log.Status)

func (*DBAdapter) CountScriptMFCCRows

func (d *DBAdapter) CountScriptMFCCRows() (int, *log.Status)

func (*DBAdapter) CountScriptRows

func (d *DBAdapter) CountScriptRows() (int, *log.Status)

func (*DBAdapter) CountWordMFCCRows

func (d *DBAdapter) CountWordMFCCRows() (int, *log.Status)

func (*DBAdapter) CountWordRows

func (d *DBAdapter) CountWordRows() (int, *log.Status)

func (*DBAdapter) DeleteMFCCs

func (d *DBAdapter) DeleteMFCCs()

func (*DBAdapter) DeleteScripts

func (d *DBAdapter) DeleteScripts(bookId string, chapterNum int) *log.Status

func (*DBAdapter) DeleteWords

func (d *DBAdapter) DeleteWords()

func (*DBAdapter) EraseDatabase

func (d *DBAdapter) EraseDatabase()

func (*DBAdapter) InsertAudioChars

func (d *DBAdapter) InsertAudioChars(words []Audio) *log.Status

func (*DBAdapter) InsertAudioVerses

func (d *DBAdapter) InsertAudioVerses(bookId string, chapter int, filename string, records []Audio) ([]Audio, *log.Status)

func (*DBAdapter) InsertAudioWords

func (d *DBAdapter) InsertAudioWords(words []Audio) ([]Audio, *log.Status)

func (*DBAdapter) InsertReplaceIdent

func (d *DBAdapter) InsertReplaceIdent(id Ident) *log.Status

func (*DBAdapter) InsertScriptMFCCS

func (d *DBAdapter) InsertScriptMFCCS(mfccs []MFCC) *log.Status

func (*DBAdapter) InsertScripts

func (d *DBAdapter) InsertScripts(records []Script) *log.Status

func (*DBAdapter) InsertWordMFCCS

func (d *DBAdapter) InsertWordMFCCS(mfccs []MFCC) *log.Status

func (*DBAdapter) InsertWords

func (d *DBAdapter) InsertWords(records []Word) *log.Status

func (*DBAdapter) SelectBookChapter

func (d *DBAdapter) SelectBookChapter() ([]Script, *log.Status)

func (*DBAdapter) SelectBookChapterFilename

func (d *DBAdapter) SelectBookChapterFilename() ([]Script, *log.Status)

func (*DBAdapter) SelectFACharTimestamps

func (d *DBAdapter) SelectFACharTimestamps() ([]generic.AlignChar, *log.Status)

func (*DBAdapter) SelectFAScriptTimestamps

func (d *DBAdapter) SelectFAScriptTimestamps(bookId string, chapter int) ([]Audio, *log.Status)

func (*DBAdapter) SelectFAWordTimestamps

func (d *DBAdapter) SelectFAWordTimestamps() ([]Audio, *log.Status)

func (*DBAdapter) SelectIdent

func (d *DBAdapter) SelectIdent() (Ident, *log.Status)

func (*DBAdapter) SelectScalarInt

func (d *DBAdapter) SelectScalarInt(sql string) (int, *log.Status)

func (*DBAdapter) SelectScriptHeadings

func (d *DBAdapter) SelectScriptHeadings() ([]Script, *log.Status)

func (*DBAdapter) SelectScriptIds

func (d *DBAdapter) SelectScriptIds() ([]Script, *log.Status)

SelectScriptIds is used by api_dbp_timestamps

func (*DBAdapter) SelectScriptLine

func (d *DBAdapter) SelectScriptLine(lineId int64) (string, *log.Status)

SelectScriptLine selects by script_id and returns one line of script text

func (*DBAdapter) SelectScriptTimestamps

func (d *DBAdapter) SelectScriptTimestamps(bookId string, chapter int) ([]Timestamp, *log.Status)

func (*DBAdapter) SelectScripts

func (d *DBAdapter) SelectScripts() ([]Script, *log.Status)

SelectScripts is used by WordParser

func (*DBAdapter) SelectScriptsByBookChapter

func (d *DBAdapter) SelectScriptsByBookChapter(bookId string, chapter int) ([]Script, *log.Status)

SelectScriptsByBookChapter ...

func (*DBAdapter) SelectScriptsByChapter

func (d *DBAdapter) SelectScriptsByChapter(bookId string, chapterNum int) ([]Script, *log.Status)

SelectScriptsByChapter is used by Compare

func (*DBAdapter) SelectUromanLine

func (d *DBAdapter) SelectUromanLine(lineId int64) (string, *log.Status)

SelectUromanLine selects by script_id and returns one line of script text

func (*DBAdapter) SelectWordTimestamps

func (d *DBAdapter) SelectWordTimestamps(bookId string, chapter int) ([]Timestamp, *log.Status)

func (*DBAdapter) SelectWords

func (d *DBAdapter) SelectWords() ([]Word, *log.Status)

SelectWords is used by encode.FastText

func (*DBAdapter) SelectWordsByBookChapter

func (d *DBAdapter) SelectWordsByBookChapter(bookId string, chapter int) ([]Word, *log.Status)

SelectWordsByBookChapter is used by Aeneas and mms_fa

func (*DBAdapter) UpdateASRLanguage

func (d *DBAdapter) UpdateASRLanguage(isoCode string) *log.Status

func (*DBAdapter) UpdateEraseScriptText

func (d *DBAdapter) UpdateEraseScriptText() *log.Status

func (*DBAdapter) UpdateIdent

func (d *DBAdapter) UpdateIdent(ident Ident) *log.Status

func (*DBAdapter) UpdateScriptFATimestamps

func (d *DBAdapter) UpdateScriptFATimestamps(audio []Audio) *log.Status

func (*DBAdapter) UpdateScriptText

func (d *DBAdapter) UpdateScriptText(audio []Audio) (int, *log.Status)

func (*DBAdapter) UpdateScriptTimestamps

func (d *DBAdapter) UpdateScriptTimestamps(scripts []Timestamp) *log.Status

func (*DBAdapter) UpdateUromanText

func (d *DBAdapter) UpdateUromanText(scripts []Script) (int, *log.Status)

func (*DBAdapter) UpdateWordEncodings

func (d *DBAdapter) UpdateWordEncodings(words []Word) *log.Status

func (*DBAdapter) UpdateWordFATimestamps

func (d *DBAdapter) UpdateWordFATimestamps(audio []Audio) *log.Status

func (*DBAdapter) UpdateWordTimestamps

func (d *DBAdapter) UpdateWordTimestamps(words []Timestamp) *log.Status

type Ident

type Ident struct {
	DatasetId      int64
	BibleId        string
	AudioOTId      string
	AudioNTId      string
	TextOTId       string
	TextNTId       string
	TextSource     request.MediaType
	LanguageISO    string
	ASRLanguageISO string
	VersionCode    string
	LanguageId     int
	RolvId         int
	Alphabet       string
	LanguageName   string
	VersionName    string
}

type MFCC

type MFCC struct {
	Id   int
	Rows int
	Cols int
	MFCC [][]float32
}

type Script

type Script struct {
	ScriptId      int
	DatasetId     int
	BookId        string
	ChapterNum    int
	ChapterEnd    int
	VerseStr      string
	VerseEnd      string
	VerseNum      int
	AudioFile     string
	ScriptNum     string
	UsfmStyle     string
	Person        string
	Actor         string
	ScriptText    string
	URoman        string
	ScriptTexts   []string
	ScriptBeginTS float64
	ScriptEndTS   float64
}

type Timestamp

type Timestamp struct {
	Id        int
	VerseStr  string
	AudioFile string
	Text      string
	BeginTS   float64
	EndTS     float64
}

type Word

type Word struct {
	VerseStr    string
	WordId      int
	ScriptId    int
	WordSeq     int
	VerseNum    int
	TType       string
	Word        string
	WordBeginTS float64
	WordEndTS   float64
	FAScore     float64
	WordEncoded []float64
}

Jump to

Keyboard shortcuts

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