To show shared highlights of the same passage between different versions of the same book.
Algorithm Drafts
Matching book
Create postgres database with pg_trgm extension.
Create the table Book(id, name, author, publisher) with an indexed column for book name.
For each book, fetch book metadata
Book Name
Author
Publisher
Preprocess book name and author name
Remove spaces, punctuation, brackets[](){}, as well as content inside brackets. Keep alphanumerical characters and Japanese characters.
Execute similarity match on the Book table book column with the book name.
If similarity exceeds threshold, check the similarity of author name.
If both book and author name exceeds respective thresholds, or if author name in either book is empty, match success and grab the book id.
If no matches, create new book row with the preprocessed metadata.
Matching highlights
Create the table Highlights(id, bookId, content, chapter, page, progress_percentage, prefix, suffix) with indexes for content and progress_percentage.
On load book, query highlight count with the bookId
If highlight count == 0, do nothing
If highlight count > 0 && <= 100, grab all highlights
if highlight count > 100, grab all highlights limit 100 where highlights progress_percentage < (current_percentage +- 20%)
Given current page number n, grab all text between n-2 to n+2.
For each highlight, preprocess it (remove spaces, punctuation, brackets and content within brackets).
Preprocess the grabbed text as well and do an exact match to see if any highlights exist in the text.
If exists, check if prefix (sentence) and suffix (sentence) matches.
If match, select text node on the reader and display the highlight.
On creating a new highlight, save the content, prefix, suffix, chapter and page. (Chapters and pages are for reference purposes.) Progress percentage is calculated on first creation.
Notes: It might be helpful to update the progress percentage with a Gaussian Bayes model.
Objective:
To show shared highlights of the same passage between different versions of the same book.
Algorithm Drafts
Matching book
Matching highlights
Notes: It might be helpful to update the progress percentage with a Gaussian Bayes model.