Wolfram Language

Multilingual Functionality

Letters within a Text

The Japanese language uses three different writing scripts.

In[1]:=
Click for copyable input
Entity["Language", "Japanese"]["WritingScripts"]
Out[1]=

These are the hiragana characters.

In[2]:=
Click for copyable input
hiraganaCharacters = Alphabet[Entity["WritingScript", "Hiragana::jx343"]]
Out[2]=

Highlight hiragana characters in the following Japanese text.

In[3]:=
Click for copyable input
text = "汚れつちまつた悲しみに 今日も小雪の降りかかる 汚れつちまつた悲しみに 今日も風さへ吹きすぎる 汚れつちまつた悲しみは たとへば狐の革裘 汚れつちまつた悲しみは 小雪のかかつてちぢこまる 汚れつちまつた悲しみは なにのぞむなくねがふなく 汚れつちまつた悲しみは 倦怠のうちに死を夢む 汚れつちまつた悲しみに いたいたしくも怖気づき 汚れつちまつた悲しみに なすところもなく日は暮れ\[Ellipsis]\[Ellipsis]";
show complete Wolfram Language input
In[4]:=
Click for copyable input
StringReplace[text, x_ /; MatchQ[RemoveDiacritics[x], Alternatives @@ hiraganaCharacters] :> ToString[Style[x, FontColor -> Red], StandardForm]]
Out[4]=

Use WordCloud to show the relative frequency of hiragana characters in the text.

In[5]:=
Click for copyable input
WordCloud[ StringCases[text, x_ /; MatchQ[RemoveDiacritics[x], Alternatives @@ hiraganaCharacters]]]
Out[5]=

Related Examples

de es fr ja ko pt-br ru zh