Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Anki integration with Jisho.org and more #49

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

carloscheddar
Copy link

Updates the existing Anki integration with more fields in order to create more detailed cards that include translations, more definitions, sound search improvements, etc. I've included a sample Anki deck which I've been using with this implementation.

anki-powered-up
anki-update
anki-preview

anki-settings

Changes

  • Integrate a Jisho.org search to the existing dictionary functionality.
  • Add settings toggle to prefer jisho.org results rather than the provided dictionaries.
  • Move Anki logic form the logs.js file into a new ankicard.js file.
  • Update glossary logic so that all entries with the same sequence are used when fetching the definition of the card. Separate entries will be added as a list and show "parts of speech" above the entry if they exist.
  • Add the sentence translation to the Anki card and add the field to the anki settings.
  • Allow parsing of structured-content if the provided user dictionary uses this.
  • Choose the dictionary entry to be used by sorting based on tags and required fields similar to yomichan instead of just grabbing the first result.
  • Remove glossary entries that are not definitiens via extractOtherForms.
  • When playing word audio use the existing audioUrl to consolidate this logic.
  • When fetching the word audio ensure that the same glossary entry displayed is the one being fetched.
  • When fetching the word audio convert "katana" to "hiragana" to receive better results.
  • When audio fails to be fetched retry without the "kanji" to see if we get a result.
  • Update card styling to allow "parts of speech" to be shown as well as several glossary entries.

This makes it so that the most common definition is the one that will be
shown in the anki card. Other definitions will be ignored.
Return jisho entries in an API compatible format to the existing look_up method
…sho entries

- Store them in separate objects in order to access unique keys easily
- Add prioritizedTags array to further prioritize specific tags
@mathewthe2
Copy link
Owner

mathewthe2 commented May 30, 2023

I'm fine with adding options to allow online dictionaries, but can you explain the motivation for preferring that as the default over a local dictionary?

Also, there are way too many commits for this one PR, many of which seemingly unrelated to the core function of adding jisho aoi, for example, function refactors, and moving logic to files.

It would be great if you can break up those changes to separate PRs.

@carloscheddar
Copy link
Author

So the way I came about this was that I wanted to use JMDict Extra to match my yomichan dictionary but the structured content couldn't be read by Game2Text. After I fixed that I realized that I wanted to add richer data to the Anki card which would need "parts of speech"(adjective, noun, ichidan verb, etc.) while this is available in dictionaries the jisho api that I've used before offered an easier way to access this data so I went ahead and implemented that. I also noticed that some yomichan results had audio while the same entry didn't have audio on Game2Text so I looked into why that was and fixed that.

I agree about the long PR I got carried away trying to make things work like I wanted to on my end that I forgot to break it down into parts. I'll look into making separate PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants