Documentation
¶
Index ¶
- func CalculateResourcePaths(docID string, parsedItem *models.ParsedItem) []string
- func GenerateDocumentID(sourceInfo *models.SourceInfo, documentData models.DocumentData) string
- type SQLiteStore
- func (s *SQLiteStore) Close() error
- func (s *SQLiteStore) DeleteDocument(ctx context.Context, docID string) error
- func (s *SQLiteStore) DocumentExists(ctx context.Context, docID string) (bool, error)
- func (s *SQLiteStore) GetCitekeyMap(ctx context.Context) (map[string]string, error)
- func (s *SQLiteStore) GetDocumentByCitekey(ctx context.Context, citekey string) (string, error)
- func (s *SQLiteStore) GetEndnote(ctx context.Context, docID string, endnoteIndex int) (*models.Endnote, error)
- func (s *SQLiteStore) GetEndnotes(ctx context.Context, docID string) ([]models.Endnote, error)
- func (s *SQLiteStore) GetFootnote(ctx context.Context, docID string, footnoteIndex int) (*models.Footnote, error)
- func (s *SQLiteStore) GetFootnotes(ctx context.Context, docID string) ([]models.Footnote, error)
- func (s *SQLiteStore) GetImage(ctx context.Context, docID string, imageIndex int) (*models.Image, error)
- func (s *SQLiteStore) GetImages(ctx context.Context, docID string) ([]models.Image, error)
- func (s *SQLiteStore) GetMetadata(ctx context.Context, docID string) (*models.ItemMetadata, error)
- func (s *SQLiteStore) GetPage(ctx context.Context, docID string, pageNum int) (string, error)
- func (s *SQLiteStore) GetPageBySourceNumber(ctx context.Context, docID string, sourcePageNum string) (string, error)
- func (s *SQLiteStore) GetPageMapping(ctx context.Context, docID string) (map[string]int, error)
- func (s *SQLiteStore) GetPages(ctx context.Context, docID string) ([]string, error)
- func (s *SQLiteStore) GetParsedItem(ctx context.Context, docID string) (*models.ParsedItem, error)
- func (s *SQLiteStore) GetQuotation(ctx context.Context, docID string, quotationIndex int) (*models.Quotation, error)
- func (s *SQLiteStore) GetQuotations(ctx context.Context, docID string) ([]models.Quotation, error)
- func (s *SQLiteStore) GetReference(ctx context.Context, docID string, refIndex int) (*models.Reference, error)
- func (s *SQLiteStore) GetReferences(ctx context.Context, docID string) ([]models.Reference, error)
- func (s *SQLiteStore) GetSummary(ctx context.Context, docID string) (string, error)
- func (s *SQLiteStore) GetTable(ctx context.Context, docID string, tableIndex int) (*models.Table, error)
- func (s *SQLiteStore) GetTables(ctx context.Context, docID string) ([]models.Table, error)
- func (s *SQLiteStore) ListDocuments(ctx context.Context) ([]models.DocumentInfo, error)
- func (s *SQLiteStore) StoreParsedItem(ctx context.Context, docID string, item *models.ParsedItem, ...) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateResourcePaths ¶
func CalculateResourcePaths(docID string, parsedItem *models.ParsedItem) []string
CalculateResourcePaths generates all available resource URIs for a parsed document. Returns a slice of resource paths based on the content available in the parsed item.
func GenerateDocumentID ¶
func GenerateDocumentID(sourceInfo *models.SourceInfo, documentData models.DocumentData) string
GenerateDocumentID creates a unique document ID from source info and document data. This function can be called before parsing to check if a document already exists. Priority: Zotero ID > URL hash > document data hash
Types ¶
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore implements the Store interface using SQLite
func NewSQLiteStore ¶
func NewSQLiteStore(dbPath string, log logger.Logger) (*SQLiteStore, error)
NewSQLiteStore creates a new SQLite store
func (*SQLiteStore) Close ¶
func (s *SQLiteStore) Close() error
Close closes the database connection
func (*SQLiteStore) DeleteDocument ¶
func (s *SQLiteStore) DeleteDocument(ctx context.Context, docID string) error
DeleteDocument removes a document and all associated data
func (*SQLiteStore) DocumentExists ¶
DocumentExists checks if a document with the given ID already exists
func (*SQLiteStore) GetCitekeyMap ¶
GetCitekeyMap retrieves all docID→citekey mappings
func (*SQLiteStore) GetDocumentByCitekey ¶
GetDocumentByCitekey retrieves a document ID by its citekey
func (*SQLiteStore) GetEndnote ¶
func (s *SQLiteStore) GetEndnote(ctx context.Context, docID string, endnoteIndex int) (*models.Endnote, error)
GetEndnote retrieves a specific endnote by index (0-indexed)
func (*SQLiteStore) GetEndnotes ¶
GetEndnotes retrieves all endnotes for a document
func (*SQLiteStore) GetFootnote ¶
func (s *SQLiteStore) GetFootnote(ctx context.Context, docID string, footnoteIndex int) (*models.Footnote, error)
GetFootnote retrieves a specific footnote by index (0-indexed)
func (*SQLiteStore) GetFootnotes ¶
GetFootnotes retrieves all footnotes for a document
func (*SQLiteStore) GetImage ¶
func (s *SQLiteStore) GetImage(ctx context.Context, docID string, imageIndex int) (*models.Image, error)
GetImage retrieves a specific image by index (0-indexed)
func (*SQLiteStore) GetMetadata ¶
func (s *SQLiteStore) GetMetadata(ctx context.Context, docID string) (*models.ItemMetadata, error)
GetMetadata retrieves metadata for a document by ID
func (*SQLiteStore) GetPage ¶
GetPage retrieves a specific page by document ID and page number (1-indexed sequential)
func (*SQLiteStore) GetPageBySourceNumber ¶
func (s *SQLiteStore) GetPageBySourceNumber(ctx context.Context, docID string, sourcePageNum string) (string, error)
GetPageBySourceNumber retrieves a page by its source page number (e.g., "125", "iv")
func (*SQLiteStore) GetPageMapping ¶
GetPageMapping returns a map of source page numbers to sequential page numbers
func (*SQLiteStore) GetParsedItem ¶
func (s *SQLiteStore) GetParsedItem(ctx context.Context, docID string) (*models.ParsedItem, error)
GetParsedItem retrieves a complete ParsedItem for a document by ID
func (*SQLiteStore) GetQuotation ¶
func (s *SQLiteStore) GetQuotation(ctx context.Context, docID string, quotationIndex int) (*models.Quotation, error)
GetQuotation retrieves a specific quotation by index (0-indexed)
func (*SQLiteStore) GetQuotations ¶
GetQuotations retrieves all quotations for a document
func (*SQLiteStore) GetReference ¶
func (s *SQLiteStore) GetReference(ctx context.Context, docID string, refIndex int) (*models.Reference, error)
GetReference retrieves a specific reference by index (0-indexed)
func (*SQLiteStore) GetReferences ¶
GetReferences retrieves all references for a document
func (*SQLiteStore) GetSummary ¶
GetSummary retrieves the summary for a document by ID
func (*SQLiteStore) GetTable ¶
func (s *SQLiteStore) GetTable(ctx context.Context, docID string, tableIndex int) (*models.Table, error)
GetTable retrieves a specific table by index (0-indexed)
func (*SQLiteStore) ListDocuments ¶
func (s *SQLiteStore) ListDocuments(ctx context.Context) ([]models.DocumentInfo, error)
ListDocuments returns a list of all stored document IDs with their metadata
func (*SQLiteStore) StoreParsedItem ¶
func (s *SQLiteStore) StoreParsedItem(ctx context.Context, docID string, item *models.ParsedItem, sourceInfo *models.SourceInfo) error
StoreParsedItem stores a parsed PDF with the provided document ID
type Store ¶
type Store interface {
// StoreParsedItem stores a parsed PDF with the provided document ID
StoreParsedItem(ctx context.Context, docID string, item *models.ParsedItem, sourceInfo *models.SourceInfo) error
// GetMetadata retrieves metadata for a document by ID
GetMetadata(ctx context.Context, docID string) (*models.ItemMetadata, error)
// GetPage retrieves a specific page by document ID and page number (1-indexed sequential)
GetPage(ctx context.Context, docID string, pageNum int) (string, error)
// GetPageBySourceNumber retrieves a page by its source page number (e.g., "125", "iv")
GetPageBySourceNumber(ctx context.Context, docID string, sourcePageNum string) (string, error)
// GetPages retrieves all pages for a document
GetPages(ctx context.Context, docID string) ([]string, error)
// GetPageMapping returns a map of source page numbers to sequential page numbers
GetPageMapping(ctx context.Context, docID string) (map[string]int, error)
// GetReferences retrieves all references for a document
GetReferences(ctx context.Context, docID string) ([]models.Reference, error)
// GetReference retrieves a specific reference by index (0-indexed)
GetReference(ctx context.Context, docID string, refIndex int) (*models.Reference, error)
// GetImages retrieves all images for a document
GetImages(ctx context.Context, docID string) ([]models.Image, error)
// GetImage retrieves a specific image by index (0-indexed)
GetImage(ctx context.Context, docID string, imageIndex int) (*models.Image, error)
// GetTables retrieves all tables for a document
GetTables(ctx context.Context, docID string) ([]models.Table, error)
// GetTable retrieves a specific table by index (0-indexed)
GetTable(ctx context.Context, docID string, tableIndex int) (*models.Table, error)
// GetFootnotes retrieves all footnotes for a document
GetFootnotes(ctx context.Context, docID string) ([]models.Footnote, error)
// GetFootnote retrieves a specific footnote by index (0-indexed)
GetFootnote(ctx context.Context, docID string, footnoteIndex int) (*models.Footnote, error)
// GetEndnotes retrieves all endnotes for a document
GetEndnotes(ctx context.Context, docID string) ([]models.Endnote, error)
// GetEndnote retrieves a specific endnote by index (0-indexed)
GetEndnote(ctx context.Context, docID string, endnoteIndex int) (*models.Endnote, error)
// GetQuotations retrieves all quotations for a document
GetQuotations(ctx context.Context, docID string) ([]models.Quotation, error)
// GetQuotation retrieves a specific quotation by index (0-indexed)
GetQuotation(ctx context.Context, docID string, quotationIndex int) (*models.Quotation, error)
// ListDocuments returns a list of all stored document IDs with their metadata
ListDocuments(ctx context.Context) ([]models.DocumentInfo, error)
// DeleteDocument removes a document and all associated data
DeleteDocument(ctx context.Context, docID string) error
// DocumentExists checks if a document with the given ID already exists
DocumentExists(ctx context.Context, docID string) (bool, error)
// GetParsedItem retrieves a complete ParsedItem for a document by ID
GetParsedItem(ctx context.Context, docID string) (*models.ParsedItem, error)
// GetCitekeyMap retrieves all docID→citekey mappings
GetCitekeyMap(ctx context.Context) (map[string]string, error)
// GetDocumentByCitekey retrieves a document ID by its citekey
GetDocumentByCitekey(ctx context.Context, citekey string) (string, error)
// Close closes the database connection
Close() error
}
Store defines the interface for storing and retrieving parsed PDF data