Wolfram Research

Function Repository Resource:

FuriganaForm

Source Notebook

Show kana with a piece of Japanese text that indicates the pronunciation of kanji

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["FuriganaForm"]["string"]

shows the Japanese text "string" along with kana that indicate the pronounciation of the kanji in "string".

Details and Options

FuriganaForm accepts the following options:
"Direction" "Horizontal" which direction to display text in
"EmptyFuriganaStyle" {FontSize0.5×Inherited} styles for the empty spaces between furigana characters
"FuriganaStyle" {FontSize0.5×Inherited} styles for the furigana characters
"GridOptions" { } options for the underlying Grid
"IncludeAudio" False include a button to play audio from SpeechSynthesize
"Reading" "Hiragana" which writing system to use for writing furigana
"Romaji" Tooltip how to display romaji readings
"TextStyle" {FontSize1.5×Inherited} overall text style
"Voice" Automatic a voice from VoiceStyleData to use when setting "IncludeAudio"True
Possible values for "Direction" are "Horizontal" and "Vertical".
For the "EmptyFuriganaStyle", "FuriganaStyle" and "TextStyle" options, any values that are accepted by Style can be used.

Examples

Basic Examples

View Japanese text with furigana inserted above kanji:

In[1]:=
ResourceFunction["FuriganaForm"]["私の猫は私に日本語を教えています"]
Out[1]=
In[2]:=
ResourceFunction["FuriganaForm"]["私の日本語能力はジャガイモのようなものですか?"]
Out[2]=
In[3]:=
ResourceFunction["FuriganaForm"]["はい!でも、頑張っています!"]
Out[3]=

Use custom styling:

In[4]:=
ResourceFunction["FuriganaForm"]["私の猫は電車の駅で野菜を売ります。", "TextStyle" -> 30, "FuriganaStyle" -> {12, Red, Bold}]
Out[4]=
In[5]:=
ResourceFunction["FuriganaForm"]["あなたの猫は何を売りますか?", "GridOptions" -> {Frame -> All, Spacings -> 0.25}, "EmptyFuriganaStyle" -> {Background -> GrayLevel[.9]}]
Out[5]=

Display vertical text (縦書き):

In[6]:=
ResourceFunction["FuriganaForm"]["春夏秋冬", "Direction" -> "Vertical", "TextStyle" -> 43, "FuriganaStyle" -> {FontSize -> 20, Gray}]
Out[6]=
In[7]:=
ResourceFunction["FuriganaForm"]["縦書き", "Direction" -> "Vertical", "TextStyle" -> {White, FontSize -> 50}, "FuriganaStyle" -> {FontSize -> 20, GrayLevel[.25], Background -> White}, "GridOptions" -> {Background -> Darker[Red]}]
Out[7]=

Options

Direction

Use "Horizontal" or Right for horizontal text (横書き):

In[8]:=
ResourceFunction["FuriganaForm"]["左横書き", "Direction" -> "Horizontal"]
Out[8]=
In[9]:=
ResourceFunction["FuriganaForm"]["左から右へ", "Direction" -> Right]
Out[9]=

Use "Vertical" or Bottom for vertical text (縦書き):

In[10]:=
ResourceFunction["FuriganaForm"]["縦書き", "Direction" -> "Vertical"]
Out[10]=
In[11]:=
ResourceFunction["FuriganaForm"]["上から下へ", "Direction" -> Bottom]
Out[11]=

Reading

Specify which writing system to use for furigana text:

In[12]:=
ResourceFunction["FuriganaForm"]["平仮名", "Reading" -> "Hiragana"]
Out[12]=
In[13]:=
ResourceFunction["FuriganaForm"]["片仮名", "Reading" -> "Katakana"]
Out[13]=
In[14]:=
ResourceFunction["FuriganaForm"]["ローマ字", "Reading" -> "Romaji"]
Out[14]=

Romaji

Show romaji text underneath:

In[15]:=
ResourceFunction["FuriganaForm"]["猫が好きです。", "Romaji" -> Below]
Out[15]=

See a tooltip when hovering over each word:

In[16]:=
ResourceFunction["FuriganaForm"]["猫が好きです。", "Romaji" -> Tooltip]
Out[16]=

FuriganaStyle

Change the styling of the furigana text:

In[17]:=
ResourceFunction["FuriganaForm"]["紫色の文字", "FuriganaStyle" -> Purple]
Out[17]=

Use multiple style specifications:

In[18]:=
ResourceFunction["FuriganaForm"]["紫色の大文字", "FuriganaStyle" -> {White, FontSize -> 20, Background -> Purple}]
Out[18]=

EmptyFuriganaStyle

Control the display of the empty space between furigana characters:

In[19]:=
ResourceFunction["FuriganaForm"]["黒い空の空隙", "EmptyFuriganaStyle" -> {Background -> Black}]
Out[19]=
In[20]:=
ResourceFunction["FuriganaForm"]["これは多くの四角があります", "EmptyFuriganaStyle" -> {Frame -> True, Background -> GrayLevel[.9]}]
Out[20]=

TextStyle

Format the overall text:

In[21]:=
ResourceFunction["FuriganaForm"]["赤いです", "TextStyle" -> {Red, FontSize -> 40}]
Out[21]=

GridOptions

Specify options for the grid:

In[22]:=
ResourceFunction["FuriganaForm"]["これは多くの四角があります", "GridOptions" -> {Frame -> All, Alignment -> Left, Spacings -> 0.5, ItemStyle -> Purple}]
Out[22]=

IncludeAudio

Include spoken audio for the text:

In[23]:=
ResourceFunction["FuriganaForm"]["私の猫は私に日本語を教えています", "IncludeAudio" -> True]
Out[23]=

Voice

Use a specific voice for the audio:

In[24]:=
voice = RandomChoice[VoiceStyleData[#Language === "Japanese" &]]
Out[24]=
In[25]:=
ResourceFunction["FuriganaForm"]["庭には二羽鶏", "IncludeAudio" -> True, "Voice" -> voice]
Out[25]=

Applications

Display some text with furigana and romaji:

In[26]:=
sample = StringSplit[
   Snippet[ExampleData[{"Text", "UNHumanRightsJapanese"}], 3], "、"];
In[27]:=
Column[ResourceFunction["FuriganaForm"][#, "Romaji" -> Below, "GridOptions" -> {Alignment -> Left}] & /@ sample]
Out[27]=

Use IntegerString to get Japanese numbers with their pronunciations:

In[28]:=
Grid[Partition[
  Table[ResourceFunction["FuriganaForm"][IntegerString[n, "Japanese"],
     "Romaji" -> Below], {n, 50}], 5], Frame -> All]
Out[28]=

Properties and Relations

FuriganaForm is just a formatting wrapper and should only be used for display purposes:

In[29]:=
ResourceFunction["FuriganaForm"]["これは箱形です"]
Out[29]=
In[30]:=
InputForm[%]
Out[30]=

JapaneseTextTokenizer is better suited to extract computable data from Japanese text:

In[31]:=
ResourceFunction["JapaneseTextTokenizer"]["これは実際のデータです。", "Dataset"]
Out[31]=

Possible Issues

FuriganaForm can be slow the first time running in a session since it needs to initialize JapaneseTextTokenizer:

In[32]:=
Clear[ResourceFunction["JapaneseTextTokenizer"]]
In[33]:=
AbsoluteTiming[
 RawBoxes[ToBoxes[ResourceFunction["FuriganaForm"]["遅いです"]]]]
Out[33]=

Subsequent evaluations will be much faster:

In[34]:=
AbsoluteTiming[
 RawBoxes[ToBoxes[ResourceFunction["FuriganaForm"]["速いです"]]]]
Out[34]=

There will not be any furigana to display if there is no kanji in the text:

In[35]:=
ResourceFunction["FuriganaForm"]["どうもありがとうロボトさん"]
Out[35]=

FuriganaForm can still be used to display the romaji transliteration, however:

In[36]:=
ResourceFunction["FuriganaForm"]["どうもありがとうロボトさん", "Romaji" -> Below]
Out[36]=

Neat Examples

Here’s a pretty neat example:

In[37]:=
ResourceFunction["BirdSay"][
 Hyperlink[
  ResourceFunction["FuriganaForm"]["私はあなたが「BirdSay」を見に行くべきだと思います", "Romaji" -> Below], ResourceFunction["BirdSay", "DocumentationLink"]]]
Out[37]=

Resource History

See Also

License Information