So you’ve followed my previous tutorial and set up this beautiful environment for creating vocabulary cards with audio and furigana based on text you read online. Yet, while studying your new set you feel this nagging feeling… There’s something’s missing still… “Hm, could it be…?”, you ponder quietly. Yes. Japanese example sentences for context!


One of the common pitfalls of learning Japanese vocabulary through ankicards is memorizing them loose of context. Perhaps you’ve found yourself in a situation having no particular problems recalling vocabulary whilst reviewing your anki cards, but less so when confronted with real-life situations. If that sounds familar, one way to counter this common problem would be to install an additional Anki add-on, and bring our vocab cards to a next level by adding Japanese example sentences and their translations. This blog offers an easy step-by-step tutorial on setting this 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 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 such a cool place). 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 copypaste 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 notetype and two test-notes for download: Example set Rikai .

Set-up

The notetypes of the vocabulary you want sentences for will need a new field to contain these. On the desktop Anki application, press CTRL-SHIFT-N, or click ToolsManage Note Types, to enter the notetype management screen. Select the notetype 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 notetype management screen, click cards. We’ll edit our lay-out and add the sentences in our actual cards.

Anki Note Lay-out

Add below’s code at 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 below’s HTML code at 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

When done, close both this and the previous screen. Let’s try this plug-in out now!

Usage

Contextualizing existing cards

We’ll start by adding example sentences to our existing cards (of the notetype we’ve just editted). 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 sexy new example sentences by now.

center border

Contextualizing new cards

While creating a new card of a notetype 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 for this.

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. I’ve 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 editted 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\your_username\Documents\Anki\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 = []).

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 editted 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 below’s line 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 n[DEST_FIELD]:
    note[DEST_FIELD] = examples

Finally, I’ve editted the mark-up of the example sentences themselves to hide the english translations unless hovered above (or on press on smartphones).

Locate the examples.append call in the find_examples method. You’ll want to replace it (I commented it out) with below’s line. 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 below’s line. We want only one break between example sentences.

return "<br>".join(examples)

Important! For this to work, you’ll need to make an edit in your note template’s layout. As usual enter the notetype management screen by pressing CTRL-SHIFT-N, or click ToolsManage Note Types. Select the notetype of the cards you’d like to contain example sentences and click fields. From there, select the Rikai note, click cards and add below’s 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 online 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 below’s “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 editting 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 on increasing your study efficiency, as well as hopefully create an attitude of self-reliability by reaching out various 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 online 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 no… It’s stronger as myself…