uribo / zipangu

Japanese utility functions and data
https://uribo.github.io/zipangu
Other
56 stars 7 forks source link

kana(): Create kana vector #43

Closed uribo closed 2 years ago

uribo commented 2 years ago

Summary

42 で提案された仮名のベクトルを生成する関数を kana()として実装。この関数は平仮名と片仮名のベクトルを出力するための関数 hiragana()および katakana()を内包している(両関数ともexportされる)。

濁音や小書き文字(捨て仮名)を含めるかどうかを引数によって指定できる。

# type により、平仮名と片仮名の指定を行う
kana(type = "hira") # デフォルトでは五十音に含まれる文字を返却
#>  [1] "あ" "い" "う" "え" "お" "か" "き" "く" "け" "こ" "さ" "し" "す" "せ" "そ"
#> [16] "た" "ち" "つ" "て" "と" "な" "に" "ぬ" "ね" "の" "は" "ひ" "ふ" "へ" "ほ"
#> [31] "ま" "み" "む" "め" "も" "や" "ゆ" "よ" "ら" "り" "る" "れ" "ろ" "わ" "を"
#> [46] "ん"
kana(type = "kata", core = FALSE) # 五十音の文字を core で制御する
#> Warning: There is no matching character. Please specify TRUE for either
#> arguments.
#> character(0)

kana(type = "hira", core = FALSE, kogaki = TRUE) # 小書き文字を含める
#>  [1] "ぁ" "ぃ" "ぅ" "ぇ" "ぉ" "っ" "ゃ" "ゅ" "ょ" "ゎ" "ゕ" "ゖ"
kana(type = "hira", core = FALSE, dakuon = TRUE, handakuon = TRUE) # 濁音、半濁音を含める
#>  [1] "が" "ぎ" "ぐ" "げ" "ご" "ざ" "じ" "ず" "ぜ" "ぞ" "だ" "ぢ" "づ" "で" "ど"
#> [16] "ば" "ぱ" "び" "ぴ" "ぶ" "ぷ" "べ" "ぺ" "ぼ" "ぽ" "ゔ"

kana(type = "hira", core = FALSE, historical = TRUE) # 歴史的仮名遣い
#> [1] "ゐ" "ゑ"

# hiragana()またはkatakana()によりtypeの指定をせずに仮名文字を得ることができる
hiragana(core = TRUE)
#>  [1] "あ" "い" "う" "え" "お" "か" "き" "く" "け" "こ" "さ" "し" "す" "せ" "そ"
#> [16] "た" "ち" "つ" "て" "と" "な" "に" "ぬ" "ね" "の" "は" "ひ" "ふ" "へ" "ほ"
#> [31] "ま" "み" "む" "め" "も" "や" "ゆ" "よ" "ら" "り" "る" "れ" "ろ" "わ" "を"
#> [46] "ん"
katakana(core = FALSE, dakuon = TRUE, handakuon = TRUE)
#>  [1] "ガ" "ギ" "グ" "ゲ" "ゴ" "ザ" "ジ" "ズ" "ゼ" "ゾ" "ダ" "ヂ" "ヅ" "デ" "ド"
#> [16] "バ" "パ" "ビ" "ピ" "ブ" "プ" "ベ" "ペ" "ボ" "ポ" "ヴ"

Created on 2022-03-08 by the reprex package (v2.0.1)

Related issues

Close #42