-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement smart readings display and highlight English definition in …
…popover dictionary based on gloss
- Loading branch information
1 parent
760650b
commit b55eb1b
Showing
6 changed files
with
155 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { LexiconEntry } from "@/app/texts/Passage"; | ||
|
||
export function findEntryMatchingEnKeywords( | ||
entries: LexiconEntry[], | ||
enKeywords: string[] | ||
) { | ||
return entries.find((e) => | ||
getEntryEnKeywords(e).some((k) => enKeywords.includes(k)) | ||
); | ||
} | ||
export function getEntryEnKeywords(entry: LexiconEntry): string[] { | ||
return entry.en?.split(/[,;]/).map((s) => toEnMatchKeyword(s)) || []; | ||
} | ||
export function toEnMatchKeyword(s: string): string { | ||
return s.trim().replace(/^(an? |to |the )/g, ""); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters