So you’ve followed my previous tutorial and set up a beautiful studying environment, optimized for on-the-spot generation of stylish vocabulary cards with both audio and furigana, based solely on the Japanese text displayed in your browser. Yet, during your study-sessions you’re constantly confronted with a nagging feeling, something in the back of your head that just won’t go away… There’s something missing still… “Hm, could it be…?”, you ponder softly. Yes. Japanese example sentences for context!


One of the common pitfalls of learning Japanese vocabulary through Ankicards is memorizing vocabulary loose of context. Perhaps you’ve found yourself in a situation having no particular problems recalling vocabulary during Anki reviews, but less so when confronted with real-life situations. If that sounds familiar, one way to counter this common problem would be to install an additional Anki add-on, and bring our vocab cards to the next level by adding Japanese example sentences (and their translations). This post offers an easy step-by-step tutorial on setting that up. Additionally, for those who’ve followed my previous tutorial, I add some extra code to combine the example sentence functions with the instant-import features of the Firefox Waterfox plug-in Rikaisama.

Plug-in

We’ll use an existing Anki add-on called Japanese Example Sentences to add Japanese sentences taken from Tatoeba.org, a “collaborative, open, free and even addictive” community on producing example sentences (the Internet is can at times be a wonderful environment). The result of our work will look as follows:

center border

Download

The Japanese Example Sentences add-on has a page on Ankiweb’s plug-in page, but as usual we’ll install the plug-in using the Desktop Anki application. Go to ToolsAdd-onsBrowse & Install, and copy-paste 2413435972 in the pop-up dialog. Restart the application to complete the installation.

Edit: as user nwt mentioned in the comments, this example-set is fairly outdated. Follow the instructions left in the plug-in’s comment section to update to the most recent set.

If you want a test Anki deck to work with, I’ve uploaded an example set (the result of my previous Anki tutorial), containing the necessary ‘note-type’ and two test-‘notes’ for download: Example set Rikai .

Set-up

The ‘note-type’ of the vocabulary you want to extract sentences for will need a new ‘field’ to contain those. On the desktop Anki application, press CTRL-SHIFT-N, or click ToolsManage Note Types, to enter the ‘note-type’ management screen. Select the note-type of the cards you’d like to contain example sentences and click fields.

center border

On the next screen, click add and call the field Examples. Now close this screen. On the previous ‘note-type’ management screen, click cards. We’ll edit our lay-out and add the sentences in our actual cards.

Anki Note Lay-out

Add the code below to the bottom of the middle lay-out screen. It’ll display the example sentences to the left of your cards.

.examples {font-size:75%; text-align: left;}
.title {font-size:16px; color: #999999;}
  • Back Template

Add the HTML code below to the bottom of your different cards’ back templates. (As pointed out in the comments, lang="ja" serves to render characters correctly, rather than in simplified Chinese due Han unification.)

{{#Examples}}
<br/>
<div class="examples" lang="ja">
<span class= "title">Sentences:</span><br/>
{{furigana:Examples}}
</div>
{{/Examples}}

center border

Now close both this and the previous screen. Let’s try this plug-in out!

Usage

Contextualizing existing cards

We’ll start by adding example sentences to our existing cards (of the note-type we’ve just edited). Press b or click on “Browse” to open Anki’s Card Browser. The left of this browser has an overview of all your different sets and tags. Select the deck or tag containing the cards you’d like to edit. Press ctrl-a to select all of those and click EditBulk-add examples. Most, if not all, should contain slick new example sentences by now.

center border

Contextualizing new cards

While creating a new card of a note-type that contains the Examples field, the add-on will automatically fill in that field as soon as you’ve entered a Japanese expression in the Expression field. No further set-up is required.

Usage with Rikaisama / Real Time Import

A drawback to this plug-in is that it does not support vocab expressions using furigana, and neither can example sentences be added automatically on adding a new note through rikaisama. If you’ve been following my previous blogpost, you’ll probably want to to follow these next steps as well.

I’ve made some adjustments to both the Anki Real-Time Import add-on and the Japanese_Examples add-on. I’ve added the edited files on a new repository on my github so go ahead and replace the existing add-on files on your Anki’s add-on folder on your computer (eg. C:\Users\USER_NAME\Documents\Anki\addons or C:\Users\USER_NAME\AppData\Roaming\Anki2\addons) with the ones on there.

I’ve described all my edits below in case you’d prefer to do this manually. Feel free to skip this part if you’re not technically inclined.

Set-up

japanese_examples.py

We’ve set up our notes to show furigana on our vocabulary. This requires square brackets (eg. 気象庁[きしょうちょう]). The Anki plug-in for Japanese examples however does not support this out of the box. For that reason, I’ve added a regular expression to only use the contents up to the first square bracket as expression.

searched = re.search(r'^[^\[]+',expression)
if searched:
    expression = searched.group(0)

If you’d like to edit this yourself, add that piece of code to the find_examples class right after it defined examples as a list. it should be around line 139 (def find_examples(expression, maxitems): examples = []).

Finally, I’ve edited the mark-up of the example sentences themselves to hide the English translations unless hovered above (or on press on smart-phones).

Locate the examples.append call in the find_examples method. You’ll want to replace it (I commented it out) with the code below. It’ll be around line 174.

examples.append("<div id='eng_test'>%s<span id='eng_sentence'>%s</span></div>" % tuple(example.split('\t')))

In the find_examples_multiple method (around line 214), replace the current return with the line below. We’ll want just one break between example sentences.

return "<br>".join(examples)

Real-Time_Import_for_use_with_the_Rikaisama_Firefox_Extension.py

This extension calls on Anki’s API to create new notes. I haven’t found a way to hook Japanese_examples to external note-creation, so instead I’ve edited the real_time_import plug-in itself to call Japanese_examples at run-time.

First, we’ll have to import the japanese_examples extension to be able to call its methods. If you’re doing this set-up manually, add the line below near the top, along with the other includes (around line 30).

from japanese_examples import *

Next, I’ve written a few lines in the createNote method to call Japanese-examples’ find method at run-time and, if examples were found and our note-type has the correct destination field, add these to our newly created card. This should come before dupOrEmpty = note.dupeOrEmpty() around line 100.

# for use with Japanese examples
examples = find_examples_multiple(note, MAX_PERMANENT)

# if field is empty and examples exist
if examples and not note[DEST_FIELD]:
    note[DEST_FIELD] = examples

EDIT: DEST_FIELD is a global variable defined in japanese_examples.py. If Anki gives an error, there might be a mismatch in naming. Check the naming in japanese_examples.py and change DEST_FIELD accordingly.


Important! For this to work, you’ll need to make an edit in your note template’s layout. As usual enter the note-type management screen by pressing CTRL-SHIFT-N, or click ToolsManage Note Types. Select the note-type of the cards you’d like to contain example sentences and click fields. From there, select the Rikai note, click cards and add the next CSS code to the bottom of the shared lay-out screen in the middle.

#eng_sentence { display: none; }
#eng_test:hover #eng_sentence{ display: inherit; color: #eb4c42;}

New Usage

Contextualizing existing cards

If you’ve set up rikaisama to include ‘rikai’ as tag on new cards, this should be a breeze. Open Anki’s browser (by clicking Browse or pressing b), select the rikai tag in the left column, and press ctrl-a to select all your cards. Next, click EditBulk-add examples.

Contextualizing imported cards

If you’ve followed above steps, every time you add a new word on-line by pressing r (the Real-Time Import key) while hovering over something Japanese, it’ll automatically contain example sentences as well.

Try it out on our “Words of the Day“™!

文脈(ぶんみゃく) | 語彙(ごい)

Download Example Set

As usual, I’ve exported my own copy of this tutorial and uploaded it in case you’d like to compare or save yourself the work of editing the note template yourself.

Wait! There is more!

The main goal of this post was to introduce another less known but highly useful Anki functionality to increase your study efficiency, as well as hopefully create an attitude of self-reliability by reaching out several new tools and possibilities. If you’ve any further questions, feel free to check out the other articles in this series on Anki, or to leave a comment below.

Further reading

  • The 10 000 Sentences Method: one of the more popular on-line self-study methods seem to be the complete Japanese immersion (All Japanese All The Time) method and its 10 000 sentences style of learning: increasing the feel of a language by assimilating and internalizing 10 000 different sentences. To be honest, the arbitrary number of sentences and clickbaity descriptions make it pretty gimmicky (“Learn Japanese in just 18 months!”2), but its popularity should give some validity on the importance of example sentences in your vocab-learning.

  1. Image taken from the 2012 Japanese animated film Wolf Children by Mamoru Hosoda, used under Fair Use doctrine. 

  2. I’ve read enough blogs on learning Japanese or language acquisition to come up with my own gimmicky clickbait articles as “Use these methods to watch your Japanese learning abilities soar” or “Break the Plateau: 10 easy tips to Master Japanese” and cash in on ads or selling e-books, but honestly I’m just some guy on the Internet learning Japanese and occasionally blogging about cool, potentially useful features. Maybe if I actually sticked on studying instead of needlessly browsing the Internet I could’ve actually made such claims, but alas I can’t help myself.