First real commit. Setting up for full CI/CD and testing pipeline

This commit is contained in:
2026-11-04 22:30:59 +01:00
parent cbb843344e
commit e08c997914
26 changed files with 3561 additions and 198 deletions

39
internal/reader/engine.go Normal file
View File

@@ -0,0 +1,39 @@
package reader
import "time"
const (
MinWPM = 100
MaxWPM = 1000
)
// WordDuration calculates how long a word should be displayed
// at the specified reading speed.
func WordDuration(word string, wpm int) time.Duration {
// Enforce supported reading speed limits.
if wpm < MinWPM {
wpm = MinWPM
}
if wpm > MaxWPM {
wpm = MaxWPM
}
// Base duration for one word.
duration := time.Minute / time.Duration(wpm)
// Add pauses for punctuation.
switch {
case IsSentenceEnding(word):
duration += 300 * time.Millisecond
case IsPausePunctuation(word):
duration += 150 * time.Millisecond
}
// Allow slightly more time for longer words.
if RuneLength(word) >= 10 {
duration += 50 * time.Millisecond
}
return duration
}