Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vocabsieve/importer/GenericImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ def defineWords(self) -> None:
word = remove_punctuations(note.lookup_term)
if settings.value("bold_word", True, type=bool):
sentence = note.sentence.replace(word, f"<strong>{word}</strong>")

if note.highlight and (note.highlight != note.lookup_term):
highlight = remove_punctuations(note.highlight)
sentence = note.sentence.replace(highlight, f"<strong>{highlight}</strong>")
else:
sentence = note.sentence

Expand Down
15 changes: 11 additions & 4 deletions vocabsieve/importer/KoreaderVocabImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,30 @@ def getNotes(self):
bookmap[bookid] = bookname

reading_notes = []
for timestamp, word, title_id, prev_context, next_context in cur.execute(
"SELECT create_time, word, title_id, prev_context, next_context FROM vocabulary"):
for timestamp, word, title_id, prev_context, next_context, highlight in cur.execute(
"SELECT create_time, word, title_id, prev_context, next_context, highlight FROM vocabulary"):
if title_id in bookmap:
# highlight is only populated if the word differs from the
# lookup term, e.g. if the language changes noun endings based
# on case.
if not highlight:
highlight = word

if prev_context and next_context:
ctx = prev_context.strip() + f" {word} " + next_context.strip() # ensure space before and after
ctx = prev_context.strip() + f" {highlight} " + next_context.strip() # ensure space before and after
else:
continue
sentence = ""
for sentence_ in self.splitter.split(ctx):
if word in sentence_:
if highlight in sentence_:
sentence = sentence_
if sentence:
count += 1
#items.append((word, sentence, str(dt.fromtimestamp(timestamp).astimezone())[:19], bookmap[title_id]))
reading_notes.append(
ReadingNote(
lookup_term=word,
highlight=highlight,
sentence=sentence,
book_name=bookmap[title_id],
date=str(dt.fromtimestamp(timestamp).astimezone())[:19]
Expand Down
1 change: 1 addition & 0 deletions vocabsieve/importer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class ReadingNote:
"""Represents a highlight/note/whatever in an ereader vocab builder"""
lookup_term: str
highlight: str
sentence: str
date: str
book_name: str