diff --git a/vocabsieve/importer/GenericImporter.py b/vocabsieve/importer/GenericImporter.py
index 19ea8f5..9b97138 100644
--- a/vocabsieve/importer/GenericImporter.py
+++ b/vocabsieve/importer/GenericImporter.py
@@ -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"{word}")
+
+ if note.highlight and (note.highlight != note.lookup_term):
+ highlight = remove_punctuations(note.highlight)
+ sentence = note.sentence.replace(highlight, f"{highlight}")
else:
sentence = note.sentence
diff --git a/vocabsieve/importer/KoreaderVocabImporter.py b/vocabsieve/importer/KoreaderVocabImporter.py
index 9f0c69c..0574b29 100644
--- a/vocabsieve/importer/KoreaderVocabImporter.py
+++ b/vocabsieve/importer/KoreaderVocabImporter.py
@@ -63,16 +63,22 @@ 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
@@ -80,6 +86,7 @@ def getNotes(self):
reading_notes.append(
ReadingNote(
lookup_term=word,
+ highlight=highlight,
sentence=sentence,
book_name=bookmap[title_id],
date=str(dt.fromtimestamp(timestamp).astimezone())[:19]
diff --git a/vocabsieve/importer/models.py b/vocabsieve/importer/models.py
index 6d6b00d..0fc7bfb 100644
--- a/vocabsieve/importer/models.py
+++ b/vocabsieve/importer/models.py
@@ -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