Documentation
¶
Overview ¶
Package reader provides core RSVP (Rapid Serial Visual Presentation) speed reading logic.
Index ¶
- func ExtractText(filename string) (string, error)
- func ExtractTextFromEPUB(filename string) (string, error)
- func FindSentenceStarts(words []string) []int
- func GetORPPosition(word string) int
- func ParseText(text string) []string
- func Register(f Format)
- func SupportedFormats() []string
- type Chapter
- type ChapterExtractor
- type EPUBFormat
- type Format
- type MarkdownFormat
- func (f *MarkdownFormat) Extensions() []string
- func (f *MarkdownFormat) Extract(filename string) (string, error)
- func (f *MarkdownFormat) ExtractChapters(filename string) ([]Chapter, []string, error)
- func (f *MarkdownFormat) Name() string
- func (f *MarkdownFormat) TOC(filename string) ([]TOCEntry, error)
- type Reader
- func (r *Reader) Advance() bool
- func (r *Reader) AtEnd() bool
- func (r *Reader) CurrentChapterTitle() string
- func (r *Reader) CurrentWord() string
- func (r *Reader) GetDelay() time.Duration
- func (r *Reader) JumpToChapter(wordIndex int)
- func (r *Reader) JumpToNextSentence()
- func (r *Reader) JumpToPrevSentence()
- func (r *Reader) Progress() (current, total int)
- func (r *Reader) SetChapters(chapters []Chapter, toc []TOCEntry)
- type TOCEntry
- type TOCProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractText ¶ added in v1.1.0
ExtractText extracts text from a file, using a registered format or plain text fallback.
func ExtractTextFromEPUB ¶ added in v1.1.0
ExtractTextFromEPUB extracts all text content from an EPUB file.
func FindSentenceStarts ¶
FindSentenceStarts returns indices of words that start sentences.
func GetORPPosition ¶
GetORPPosition returns the Optimal Recognition Point index for a word. This is the character (rune) position where the eye should focus for fastest recognition.
func Register ¶ added in v1.1.0
func Register(f Format)
Register adds a format reader to the registry.
func SupportedFormats ¶ added in v1.1.0
func SupportedFormats() []string
SupportedFormats returns registered format names with their extensions.
Types ¶
type ChapterExtractor ¶ added in v1.1.0
ChapterExtractor is an optional interface for chapter-aware extraction
type EPUBFormat ¶ added in v1.1.0
type EPUBFormat struct{}
EPUBFormat implements Format for EPUB files.
func (*EPUBFormat) Extensions ¶ added in v1.1.0
func (f *EPUBFormat) Extensions() []string
func (*EPUBFormat) Extract ¶ added in v1.1.0
func (f *EPUBFormat) Extract(filename string) (string, error)
func (*EPUBFormat) ExtractChapters ¶ added in v1.1.0
func (f *EPUBFormat) ExtractChapters(filename string) ([]Chapter, []string, error)
ExtractChapters extracts text with chapter boundaries preserved.
func (*EPUBFormat) Name ¶ added in v1.1.0
func (f *EPUBFormat) Name() string
type Format ¶ added in v1.1.0
type Format interface {
Name() string
Extensions() []string
Extract(filename string) (string, error)
}
Format defines a file format reader for extracting text.
type MarkdownFormat ¶ added in v1.1.0
type MarkdownFormat struct{}
MarkdownFormat implements Format for Markdown files.
func (*MarkdownFormat) Extensions ¶ added in v1.1.0
func (f *MarkdownFormat) Extensions() []string
func (*MarkdownFormat) Extract ¶ added in v1.1.0
func (f *MarkdownFormat) Extract(filename string) (string, error)
func (*MarkdownFormat) ExtractChapters ¶ added in v1.1.0
func (f *MarkdownFormat) ExtractChapters(filename string) ([]Chapter, []string, error)
ExtractChapters extracts text with chapter boundaries from headers.
func (*MarkdownFormat) Name ¶ added in v1.1.0
func (f *MarkdownFormat) Name() string
type Reader ¶
type Reader struct {
Words []string
SentenceStarts []int
CurrentIndex int
WPM int
Paused bool
LastArrowPress time.Time
// Chapter support
Chapters []Chapter
TOC []TOCEntry
CurrentChapter int
}
Reader holds the state for an RSVP speed reading session.
func (*Reader) CurrentChapterTitle ¶ added in v1.1.0
CurrentChapterTitle returns the title of the current chapter.
func (*Reader) CurrentWord ¶
CurrentWord returns the word at the current index.
func (*Reader) JumpToChapter ¶ added in v1.1.0
JumpToChapter jumps to the specified word index and updates current chapter.
func (*Reader) JumpToNextSentence ¶
func (r *Reader) JumpToNextSentence()
JumpToNextSentence moves to the start of the next sentence.
func (*Reader) JumpToPrevSentence ¶
func (r *Reader) JumpToPrevSentence()
JumpToPrevSentence moves to the start of the previous sentence.
func (*Reader) SetChapters ¶ added in v1.1.0
SetChapters sets the chapter data and updates the current chapter.
type TOCProvider ¶ added in v1.1.0
TOCProvider is an optional interface for formats that support TOC extraction