Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Bash script to convert romaji to hiragana

  1. #11
    Join Date
    Jan 2012
    Beans
    753

    Re: Bash script to convert romaji to hiragana

    Quote Originally Posted by sisco311 View Post
    Thread moved to Programming Talk.

    There is a perl module which can do this: http://search.cpan.org/~dankogai/Lin...gua/JA/Kana.pm
    How do I put Perl in a bash script? Or do I have to write a Perl script (I don't know any Perl though)?

  2. #12
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,464
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Bash script to convert romaji to hiragana

    just like with python
    inline: python -c / perl -e
    or external .py /.pl scripts

    some knowledge of perl would be nice because it's not exactly intuitive when compared to python, but i think the general idea would be the same: pass the string, use a function provided by a module on it, voila.

    on that page you have short snippets showing how to use it.
    Last edited by Vaphell; March 23rd, 2013 at 07:54 AM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #13
    Join Date
    May 2012
    Location
    ザ・ワ&
    Beans
    152
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Bash script to convert romaji to hiragana

    Whole nother note, but I stumbled onto this post by chance, and as an anime-loving, japanese learning ubuntu-user, I should greatly like to make your acquaintance, 寒石さん
    Also, this Vaphell character is very knowledgable, he was of great assistance (read: did 99% of) in making a tool for UTAU-associated file conversion.
    Technomancy
    The old ways are not the only ways. We study the mysteries of laser and circuit, crystal and scanner. Holographic daemons and invocations of equations. These are the tools we employ, and we know many things

  4. #14
    Join Date
    Jan 2012
    Beans
    753

    Re: Bash script to convert romaji to hiragana

    Quote Originally Posted by Vaphell View Post
    just like with python
    inline: python -c / perl -e
    or external .py /.pl scripts

    some knowledge of perl would be nice because it's not exactly intuitive when compared to python, but i think the general idea would be the same: pass the string, use a function provided by a module on it, voila.

    on that page you have short snippets showing how to use it.
    How do I install it? It says to run "perl Makefile.PL" but the only downloadable file is Kana.pm.

  5. #15
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,464
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Bash script to convert romaji to hiragana

    http://www.cpan.org/modules/INSTALL.html

    i went with cpan+cpanm <module>

    Code:
    sudo cpan App::cpanminus
    sudo cpanm Lingua::JA::Kana
    but...

    Code:
    #! /usr/bin/perl -w
    
    use strict;
    use Encode;
    use Lingua::JA::Kana;
    
    my @str = ( "anata wa shin setsu desu", "konbanwa" );
    foreach (@str)
    {
      print $_.' => '.encode_utf8( Lingua::JA::Kana::romaji2hiragana($_) )."\n"; 
    }
    Code:
    $ ./test.pl
    anata wa shin setsu desu => あなた わ しん せつ です
    konbanwa => こんばんわ
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  6. #16
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Bash script to convert romaji to hiragana

    If that perl module doesn't do what you want, you can try ruby, too. There are two packages for it in the official Ubuntu repositories: ruby-romkan and libsuikyo-ruby1.8. Having been created by a Japanese, I guess ruby should have decent Japanese language conversion tools.
    Code:
    $ irb1.8
    irb(main):001:0> $KCODE='e'
    => "e"
    irb(main):002:0> require 'romkan'
    => true
    irb(main):003:0> 'konbanwa'.to_kana
    => "こんばんわ"
    irb(main):004:0> 'anata wa shin setsu desu'.to_kana
    => "あなた わ しん せつ です"
    irb(main):005:0>
    Last edited by schragge; March 24th, 2013 at 07:00 PM.

  7. #17
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,464
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Bash script to convert romaji to hiragana

    it seems to be the same romkan package python has but made for ruby and the result is the same for 'wa' わ that is supposed to be 'ha' は
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  8. #18
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Bash script to convert romaji to hiragana

    Yep, you're right. I also get the same results with suikyo, only that it removes all spaces. I've tried it with romaji conversion table. Below are all conversion tables suikyo installs:
    Code:
    $ ls /usr/share/suikyo/conv-table/
    ascii-wideascii        kana                    skk-mark
    azik                   kana_reverse            skk-mark_reverse
    azik-all               kana-romaji             tcode
    azik-all_reverse       katakana-halfkatakana   tcode-dvorak
    azik_reverse           katakana-hiragana       tcode-dvorak_reverse
    egg-mark               kuten                   tcode_reverse
    egg-mark_reverse       kuten_reverse           tutcode
    halfkatakana-hiragana  romaji                  tutcode_reverse
    halfkatakana-katakana  romaji-hepburn_reverse  wideascii-ascii
    hiragana-halfkatakana  romaji-kana
    hiragana-katakana      romaji_reverse
    TBH, I don't know what most of them mean.

  9. #19
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,464
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Bash script to convert romaji to hiragana

    i guess these are conversions between 2 native writing schemes, between codepages and different romanization rules. Usual mess with huge syllabic/picturesque writing systems.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  10. #20
    Join Date
    Jan 2012
    Beans
    753

    Re: Bash script to convert romaji to hiragana

    I think I know what the problem is... If these were made specifically for the Japanese, it would make sense that it doesn't automatically convert. When typing Japanese on a computer, you'd type "konbanha" and would know it's pronounced "wa", but for someone like me who is NOT Japanese, I read romaji the way it's pronounced, as konbanwa.

    So if these modules are strictly for Japanese people converting characters from a western keyboard to hiragana, then that explains it. I think what I'd need is something designed for people learning Japanese.

    Well, if nothing like that's out there maybe I should just use only hiragana. Romaji is a bad habit to get into if you use it too often anyways...

    I suppose this is kind of like someone from Japan going to a Japanese forum and asking for a script which converts katakana to romaji so he can learn English, but all the scripts out there are designed for English use specifically. Of course the script won't know how to convert コンピュータ to "computer", because コンピュータ is "konpyuta" in romaji.

    Thanks for the help anyways.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •