Archive for the ‘Software’ Category

Panduan Yahoo! Jisho: Kamus Jepang Inggris dengan Banyak Contoh Kalimat

Saturday, December 8th, 2007 by Agro Rachmatullah

Saat aku sedang terhubung ke Internet, Yahoo! Jisho adalah situs kamus Jepang-Inggris yang selalu kukunjungi. Banyaknya contoh kalimat untuk tiap makna yang berbeda membuat kamus ini sangat berguna saat aku menemui kata baru. Alamatnya ada di http://dic.yahoo.co.jp. Artikel ini akan memandu kamu menggunakan situs tersebut sebagai kamus Jepang-Inggris. (Situs tersebut juga bisa digunakan sebagai kamus lain, misalnya Jepang-Jepang.)

Kamus Jepang Inggris Yahoo!

Situsnya berbahasa Jepang, namun jangan panik karena panduan ini akan menjelaskan semua bagian pada form pencarian tersebut.

Nomor 1 merupakan kotak teks untuk menulis kata yang ingin dicari. Kalau kata yang ingin dicari tersebut bersumber dari halaman web atau sejenisnya, cukup dicopy-paste ke tempat ini. Sebagai contoh, kamu bisa mencoba kata-kata berikut: わたし, アイドル, 好き. Kotak tersebut menerima hiragana, katakana, maupun kanji dari suatu kata. Contohnya, untuk mencari kata “kirei” kamu bisa memberikan きれい, キレイ , maupun 奇麗. Tentu saja kita tidak bisa memasukkan romaji, karena bahasa Jepang memang tidaklah ditulis menggunakan romaji.

Bagaimana kalau kamu ingin menuliskan katanya sendiri, tetapi di komputer kamu tidak ada IME? Kunjungi saja http://agro1986.googlepages.com/ime.htm (Uhuk, uhuk, promosi…).

Gama Web-based Japanese Input Method Editor (IME) with Ajax!!!

Pada aplikasi web tersebut, klik tombol “Turn IME On” lalu mulailah mengetik suatu kata di kotak teksnya, misalnya “sugoi”. Katanya akan langsung dirubah menjadi hiragana (sugoiiii). Tekan Enter setelah selesai mengetik katanya, lalu copy-paste hasilnya ke kotak teks Yahoo! Jisho. (Tips: Sebelum menekan Enter, tekan F7 untuk merubahnya ke katakana.)

Berikutnya, nomor 2 adalah metode pencocokan kata. Pilihannya, dari atas ke bawah, adalah:

  1. で始まる (INPUT de hajimaru): Dimulai dengan masukan. Sebagai contoh, jika masukan adalah かみ (kami), maka selain kata tersebut, kata seperti かみなり (kaminari) juga akan dicari.
  2. に一致する (INPUT ni icchi suru): Cocok persis dengan masukan. Jika memberi かみ (kami), maka hanya kata tersebut yang akan dicari.
  3. を含む (INPUT o fukumu): Berisi masukan. Dengan kata lain, masukan bisa berada di awal, tengah, maupun akhir kata. Dengan masukan かみ (kami), maka selain kata tersebut, kata seperti かみなり (kaminari), おかみさん (okamisan), dan あかみ (akami) juga akan dicari.
  4. で終わる (INPUT de owaru): Diakhiri masukan. Sebagai contoh, jika masukan adalah かみ (kami), maka selain kata tersebut, kata seperti あかみ (akami) juga akan dicari.
  5. を解説に含む (INPUT o kaisetsu ni fukumu): Berisi masukan pada penjelasannya. Sebagi contoh, jika masukan adalah かみ (kami), maka あな (ana, “lubang”) akan menjadi salah satu hasil pencarian karena halaman penjelasannya berisi contoh kalimat 「おおかみの穴」 (ookami no ana).

Pada umumnya, yang aku gunakan adalah pilihan kedua dari atas (に一致する, cocok persis).

Nomor 3 di screenshot pertama adalah pilihan kamus. Dari kiri ke kanan, pilihannya adalah:

  1. 国語 (kokugo): Kamus Jepang-Jepang. Memberikan penjelasan yang sangat mendetil mengenai tiap kata… dalam bahasa Jepang.
  2. 類語 (ruigo): Kamus sinonim. Berguna untuk mencari alternatif kata yang tidak umum untuk membuat teman-teman kamu terkagum-kagum.
  3. 英和 (eiwa): Kamus Inggris-Jepang. Ingatlah untuk memberikan masukan berupa bahasa Inggris.
  4. 和英 (waei): Kamus Jepang-Inggris. Topik yang dibahas di panduan ini.
  5. すべての辞書 (subete no jisho): Cari di semua kamus.

Kalau kamu seperti aku, yang menggunakan kamus ini saat menemukan kata baru waktu membaca, maka kamu akan memilih pilihan keempat.

Terakhir, pilih tombol yang ditandai dengan 4 pada screenshot pertama yaitu 検索 (kensaku, cari). Inilah contoh suatu hasil pencarian:

Hasil pencarian Yahoo! Dictionary

Jangan kaget kalau sekali lagi tidak ada romaji. Ayo belajar huruf Jepang yang sebenarnya! Di balik rintangan berupa sistem penulisan yang indah tersebut, kamu akan menemukan kamus ini sebagai kamus yang kaya akan contoh kalimat dan sangat berguna sebagai teman membaca kamu.

Kalau kamu menuliskan kana (hiragana ataupun katakana) sebagai masukannya, seluruh kata dengan bunyi tersebut akan dicari. Sebagi contoh, kalau kamu melakukan pencarian persis terhadap kata きく, maka kamu akan mendapatkan mulai dari 菊 (bunga Krisantemum) sampai 聞く (mendengar, bertanya).

Di lain pihak, kalau kamu menuliskan kanji sebagai masukan, maka seluruh bacaannya akan diberikan. Sebagai contoh, kalau kamu memberikan 間, maka berbagai bacaannya mulai dari あいだ (aida) sampai ま (ma) akan diperoleh.

Untuk pencarian yang mengembalikan banyak hasil tersebut, kamu bisa berganti hasil pencarian melalui kotak pilihan yang terletak di sebelah kanan:

Alternatif hasil pencarian Kamus Yahoo!

Masih banyak yang bisa dibahas dari penggunaan Yahoo! Dictionary ini, namun aku harap panduan ini sudah cukup untuk membuat kamu tertarik untuk mulai menggunakan situs tersebut. Semoga berguna!

SQLite, mesin SQL yang kecil dan cepat

Tuesday, May 29th, 2007 by Agro Rachmatullah

Waktu dulu aku mengambil mata kuliah basis data, aku menginstall server SQL kelas berat yaitu MySQL. Padahal, yang dulu ingin kulakukan hanyalah mengenal dan bermain-main dengan perintah SQL.

Berkas zip MySQL 3 yang waktu itu kusalin dari teman ukurannya sekitar 12 MB. Installer Windows MySQL 5 “Essential” ukurannya sekitar 22 MB. Adakah alternatifnya?

Mari berkenalan dengan SQLite, sebuah mesin SQL yang kecil dan cepat. Program dengan lisensi public domain ini sudah mencapai versi 3 saat artikel ini ditulis. Pada dasarnya, SQLite adalah pustaka bahasa C untuk dilink oleh program yang membutuhkannya (sqlite3.dll untuk Windows dan sqlite-3.x.x.so untuk Linux). Tersedia juga binding untuk banyak bahasa lain (misalnya System.Data.SQLite.dll untuk .NET). Contoh program yang menggunakan SQLite adalah Firefox 3 untuk basis data bookmarknya dan Banshee (pemutar musik C#) untuk basis data lagunya. Jadi dia bukanlah program server yang berjalan sendiri dan menunggu koneksi dari program lain sebagaimana MySQL.

Seluruh database (definisi, tabel, indeks, dan data) pada SQLite disimpan dalam satu berkas. Berkas ini cross platform.

Tapi kembali ke permasalahan semula. Kita ingin bermain-main dengan perintah SQL, bukannya membuat program yang menggunakan basis data. Untuk keperluan ini, di halaman download SQLite disediakan program konsol yang bisa membuat dan membaca berkas basis data SQLite. Program konsol itu sendiri merupakan contoh program yang memanfaatkan pustaka SQLite (tapi pada program ini SQLitenya dicompile bersama, tidak berada di file pustaka terpisah). Ukurannya sangat kecil, misalnya sqlite3-3.3.17.bin.gz untuk Linux berukuran 173.46 KiB dan sqlite-3_3_17.zip berukuran 174.64 KiB!

Tutorial Program Konsol SQLite

PS: Diasumsikan pembaca sudah mengerti perintah-perintah SQL dasar sehingga tidak ada penjelasan panjang lebar tentangnya. Walaupun begitu, mungkin artikel ini juga bisa dimanfaatkan sebagai tutorial kotor tentang perintah SQL.

Programnya dijalankan dengan memberikan satu argumen berupa nama berkas basis data yang diinginkan. Jika berkasnya tidak ada, maka berkas baru akan dibuat. Ekstensi berkasnya bisa sembarang. Kita akan menggunakan db3 untuk menandakan bahwa itu adalah berkas database yang dibuat SQLite versi 3. Contohnya adalah:

$ sqlite3 test.db3

(Untuk pengguna Linux, ganti nama sqlite3-3.3.17.bin atau buat symbolic link seperlunya)

Setelah mengetikkan perintah tersebut kita akan dibawa ke konsol SQL!

SQLite version 3.3.17
Enter ".help" for instructions
sqlite>

Untuk melihat tabel-tabel yang ada pada basis data yang sedang digunakan, masukkan perintah .table:

sqlite> .table
sqlite>

Perintah yang diawali titik (seperti .table) adalah perintah khusus program konsol ini. Tentu saja, kalau basis datanya baru dibuat tidak akan ada tabel apa-apa.

Kita bisa membuat tabel baru dengan perintah SQL CREATE, misalnya:

sqlite> CREATE TABLE mahasiswa(
   ...> nim INTEGER PRIMARY KEY,
   ...> nama TEXT,
   ...> prodi CHAR(2));
sqlite> .table
mahasiswa
sqlite>

Perintah untuk membuatnya adalah “CREATE TABLE mahasiswa(nim INTEGER PRIMARY KEY, nama TEXT, prodi CHAR(2));“. Walaupun begitu, pada contoh penulisan perintahnya dipecah menjadi 3 baris. Perintah SQL diakhiri dengan titik koma, jadi selama kita belum menuliskan titik koma program tersebut masih menunggu input di baris berikutnya (ditandai dengan prompt...>“). Dengan perintah .table, bisa dilihat bahwa tabelnya memang sudah tercipta.

Berikutnya adalah memasukkan data pada tabel tersebut dengan perintah SQL INSERT dan menampilkan isi tabel dengan perintah SQL SELECT:

sqlite> INSERT INTO mahasiswa(nama, prodi) VALUES('Linus Torvalds', 'IK');
sqlite> INSERT INTO mahasiswa(nama, prodi) VALUES('Richard Stallman', 'FI');
sqlite> INSERT INTO mahasiswa VALUES(9374, 'Agro', 'IK');
sqlite> INSERT INTO mahasiswa VALUES(9374, 'Wijaya', 'IK');
SQL error: PRIMARY KEY must be unique
sqlite> INSERT INTO mahasiswa(nama, prodi) VALUES('Ace Ventura', 'KH');
sqlite> SELECT * FROM mahasiswa;
1|Linus Torvalds|IK
2|Richard Stallman|FI
9374|Agro|IK
9375|Ace Ventura|KH
sqlite>

Bisa dilihat bahwa kalau kunci primer nim tidak ditentukan, maka nilainya akan ditentukan secara otomatis dimulai dari 1. Terlihat jelas juga bahwa tidak mungkin memasukkan dua baris dengan kunci primer yang sama.

Contoh perintah SELECT lain yang hanya menampilkan mahasiswa ilmu komputer (IK):

sqlite> SELECT nama,nim FROM mahasiswa WHERE prodi='IK';
Linus Torvalds|1
Agro|9374
sqlite>

Karena Richard Stallman ingin pindah dari prodi filsafat (FI) ke ilmu komputer, mari kita bantu dia dengan perintah SQL UPDATE:

sqlite> UPDATE mahasiswa SET prodi='IK' WHERE nim=2;
sqlite> SELECT * FROM mahasiswa;
1|Linus Torvalds|IK
2|Richard Stallman|IK
9374|Agro|IK
9375|Ace Ventura|KH
sqlite>

Sayangnya di ilmu komputer ada aturan bahwa rambut tidak boleh gondrong. Richard Stallman, orang yang keras kepala, lebih memilih dikeluarkan daripada harus mencukur rambutnya. Terpaksa perintah SQL DELETE dipakai:

sqlite> DELETE FROM mahasiswa WHERE nim=2;
sqlite> SELECT * FROM mahasiswa;
1|Linus Torvalds|IK
9374|Agro|IK
9375|Ace Ventura|KH
sqlite>

PS: Rambut Agro belum cukup gondrong untuk ditindak.

Dan terakhir, karena mahasiswanya tidak ada yang mampu membayar kuliah (terlalu mahal!), jadinya tidak ada yang membayar kuliah. Universitasnya pun bangkrut sehingga tabel mahasiswa tidak ada gunanya lagi. Perintah SQL DROP digunakan untuk menghapus tabel:

sqlite> DROP TABLE mahasiswa;
sqlite> .table
sqlite>

Untuk keluar dari program, gunakan perintah .q, .quit, atau .exit. Bisa dicek bahwa berkas test.db3 (atau nama lain yang dipilih) telah tercipta.

Bagaimana, keren kan? Setelah mengetahui tentang SQLite, kamu bisa merekomendasikan program ini pada teman-temanmu yang mengambil basis data.

Untuk tutorial mengenai hal-hal yang lebih kompleks (misal trigger), kunjungi tutorial di freshmeat. Untuk daftar perintah-perintah SQL yang didukung SQLite, kunjungi halaman di situs resminya. Ada benchmark (agak kuno) untuk melihat bahwa SQLite tidaklah lambat. Untuk penggunaan SQLite pada .NET (C#), mungkin kapan-kapan aku bakal bikin tutorialnya :)…

I knew it! Files are living things! They have genes!!!

Saturday, May 26th, 2007 by Agro Rachmatullah

The problematic file is freetest.htm. I have identified that it has an NS_ERROR_XPC_NOT_ENOUGH_ARGS gene. With that gene, you cannot do any AJAX from the file on certain environments…

No, I’m not on a crack… Listen to my detailed account, all you Javascript developers… That defective gene might be on YOUR file.

After learning how to use AJAX on a dummy page, I coded the real thing on freetest.htm, the real page. Like most Javascript programming, sure enough it only works on one browser. The lucky one is Opera 9 this time. The suckers are Firefox 2 and IE 6.

Browser programmers are ultra-smart guys, I assume the mistake is on my part. OK, so I copied the AJAX code to a dummy, clean, HTML page to find the bug. However it works!

Ah, so it must be some arcane interaction between the previously-existing Javascript code and the newly-added AJAX code. But my AJAX code is pretty complicated. Therefore I tried adding the simplest possible AJAX action in my real page, trying to see whether a simple AJAX works at all. The simple AJAX creates an XMLHttpRequest, sends a request, and retrieves the response. This time it works in Opera 9 and IE 5. Firefox (using Firebug debugger) gives this error:

uncaught exception: [Exception... "Not enough arguments"
nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)"
location: "JS frame :: http://localhost/aspx/freetest.htm ::
doAjax :: line 26" data: no]

It’s time to hunt which other js file conflicts with this one. I deleted the reference to other js files one by one, until there is no Javascript code other then the AJAX itself! But still AJAX doesn’t work!

Lol now that’s funny. OK, so I tried modifying my real file further (I’ve backed it up), deleting more useless things like CSS and title, until it matched another dummy file (freetest-simpleajax.htm) with the same AJAX code down to every character. Browsers are weird, so there is still the slight possibility that the TITLE tag messes things up. However it still doesn’t work while AJAX works on the other dummy file!

Obligatory md5 result:

1ab3bdf1ab23aabd6cfa4b1210bc7ee2 *freetest.htm
1ab3bdf1ab23aabd6cfa4b1210bc7ee2 *freetest-simpleajax.htm

(since the content of the files are identical, the genes must be stored somewhere else such as in the NTFS Master File Table)

Lol… I tried using the save as command to save freetest.htm into freetestxxx.htm. That’s probably the equivalent of reproduction. Amusingly, freetestxxx.htm works fine. Did the defective gene not get passed?

Ah, I forgot a very basic thing! Phenotype (visible traits, like the body height of an ape and an HTML page throwing exception) comes from the intricate interaction between genotype and the environment! Basic Biology… Let’s try opening freetest.htm on another tab of the still-running firefox.exe instance…

Result…

It works!

So, it must be the environment. The other tab must be too humid or something for freetest.htm to do AJAX. It’s not a problem of cache (the tab loading an old, nonworking version of the file). I tried modifying freetest.htm by adding visible text and reloading it on both tabs. The text appears on both, signifying that both tabs opened the most recent version of the file. However AJAX still doesn’t work on that cursed tab…

Whatever… I still haven’t achieved what I wanted, making the real AJAX code work on the real page… Back to work…

Edit: The culprit is the function named parent. Renamed it to domParent. What’s weird is that after the exception occurs, the tab will be unable to do AJAX on that page even after the problem has been corrected (hence the story above).

Edit 2: It doesn’t work in IE! The ringleader is different this time… In IE 6, there is no XMLHttpRequest required for AJAX, but we can achieve the same thing by creating an ActiveXObject as shown:

var foo = new ActiveXObject('Msxml2.XMLHTTP');

However, it turns out that the variable foo won’t behave completely like a real Javascript object! It fails when we try to dynamically add a property, such as:

foo.bar = 'This thing normally works';

My code adds an id for every XMLHttpRequest object created, so it fails miserably in IE 6… Geesh, I now have to code a different way of tracking those requests…

Writing kanji: doing it the traditional way

Wednesday, April 18th, 2007 by Agro Rachmatullah

A go player once blogged along the lines of “For an effective study, it’s not enough to see on the computer screen. To really feel the flow of the game you must pick the stones and lay it out on a real board.”

Those are wise words indeed, and applies all the same to kanji writing study.

On the early days of my kanji study, I only put “reading” questions on the flash card program Mnemosyne. Those are questions such as:

Q: 火
A: ひ (fire)

When given the question (e.g., “火”), it tests whether you know its reading and meaning. However it doesn’t test your writing ability at all.

Of course, my naive hope was that “if I know how to read it, I’ll know how to write it”. However that certainly isn’t true. For one thing, I know lots of logos (Windows, Firefox, Ubuntu, UGM, ITB, etc) but couldn’t draw them. Practicing reading will only improve your reading ability, and to be able to write there is no way other than to practice writing.

So, realizing that I forget how to draw many kanji, I started putting “writing” questions in Mnemosyne such as:

Q: ひ (fire)
A: 火

(The questions are per kanji, not per word. Therefore there are no questions such as だいがくせい (大学生) because it asks for 3 kanji)

Initially, when faced with writing questions I would draw the kanji on computer using my own program StrokeReplayer. However, writing using the mouse is clumsy so I resorted to the traditional ink and paper:

Kanji writing using ink and paper

I’m really feeling the flow of the kanji…

Recording karaoke using Audacity

Tuesday, April 10th, 2007 by Agro Rachmatullah

Audacity is a free (open source) audio recording application. It is multiplatform, with versions for Windows, Linux, and OS X. By default it outputs the final audio in ogg/vorbis, but mp3 support can be added quite easily.

In this article I’ll guide you how to record a karaoke using Audacity. What it means is that you have an instrumental (music-only) version of a song and you want to add your (horrible) sound to it.

First of all you need to have the instrumental version of the song itself. In the Japanese music scene, singles are released in CD which also includes its instrumental version so download go buy that CD and rip the audio. Audacity supports wav, mp3, ogg, and some other formats as its input.

After that download the program and install it. For this guide I’m using version 1.2.6 for Windows. The first screen should look like this:

Audacity initial screen

Now make sure your mike is plugged to the right place and the correct stream (e.g., “Mic”) is selected in the input drop down. Press the record (red circle) button and mumble some words. You’ll see a new audio track created. Press the stop (yellow square) button and try to play back by pressing the play (green arrow) button.

Audacity audio track

In the top left of every audio track, there is a small “x” button (pictured above). You can click it to delete the track. If you think the recorded volume is too loud or small, delete your first audio track, adjust the volume (the slider with a mic icon), and try another recording. When you are satisfied with the volume, you can go to the next step.

Load the instrumental version of the song from “File”->”Open…”. After the importing process is done you will see the the audio tracks. Before you start recording though, you need to make sure that Audacity plays those tracks while recording. This step is probably the most important but nonobvious. Go to “Edit”->”Preferences…”, open “Audio I/O” tab, and select “Play other tracks while recording new one” (see below).

Audacity preferences

After that you can go to the real fun. Press the record button and sing until the song ends. Your voice will be kept in a new track so if you’re not satisfied just delete the track and record again. To finish, select “File”->”Export As Ogg Vorbis…” and the resulting file can be played in any sane media player (such as VLC or Windows Media Player after installing the codecs).

Below are some stuffs which you probably want to do…

Changing pitch

If you can’t hit some note because it’s too low or high, you might want to change the pitch of the musical instruments before recording your sound. To do it, press CTRL+A (select all) and go to “Effect”->”Change Pitch…”. For example, to lower it you might select from “F” “down” to “E”. Note that the instruments will have a lower quality and sound unnatural if you do this.

MP3 export

OGG Vorbis is a free format while MP3 is proprietary so you should prefer OGG Vorbis when possible. In cases where using MP3 is a must (such as to play on MP3 players) the supports can be easily enabled.

First download LAME MP3 encoder for your operating system. Then extract the compressed file somewhere. After that go to “Edit”->”Preferences…” and open the “File Formats” tab. Press “Find Library” and browse for the requested file (e.g., lame_enc.dll for Windows). With that, you can export to MP3 from “File”->”Export As MP3…”.

Closing

I won’t give an example exported file here. Just have fun, but remember to respect your friend’s ears.

Japanese kanji handwriting recognition in Windows XP’s IME

Saturday, March 31st, 2007 by Agro Rachmatullah

Did you know that in Windows XP’s IME we can input a kanji by drawing it? (Does Ubuntu, and Linux in general, have it?) I will outlay the steps here.

Obviously you need to have the IME installed. See this Wikibook page. For illustration, we’ll use Notepad. So fire up Notepad, switch the IME on, and input any character on the keyboard. I use ‘a’, which the IME will convert to hiragana ‘あ’ on the fly:

あ on Notepad

The magic key is ‘F5′, which will launch the IME pad. Press it and you’ll get this:

IME pad welcome dialog

Press “OK” and you’ll get this:

IME pad

On the screen pictured above, you can find a kanji by its radical (部首, bushu). However that’s not what we’re interested in right now. To input by drawing, click the top-leftmost button (circled red). You’ll get this:

IME handwriting pad

Here’s the explanation for the UI elements:

  1. This is the drawing area. You draw the strokes here by holding the left mouse button and dragging.
  2. Matching shapes (and not-so-matching shapes) you draw in (1) will be listed here. If you’ve found the kanji you want, just click it.
  3. 戻す (modosu) means “to return”. Click this to undo the last stroke.
  4. 消去 (shoukyo) means “erasing”. Click this to clear the drawing area.

One thing to note is that stroke order matters! Try to draw a perfectly matching shape but with a random stroke order, and chances are the program will not give the kanji you want.

The power of this tool cannot be underestimated. For one thing, it allows you to quickly find a printed character you see. Suppose you went to a mini market and see a notice written in Japanese (for example, in Circle K Terban, Yogyakarta). If there is an unknown kanji there, you won’t have any information other than its shape. Finding the kanji through the method explained above will be very easy. After you have the digital form of the character, you can find its readings, compounds, and meanings in electronic dictionaries.

Second, you can use it to input rare kanji easily. Suppose for some insane reason you want to write “koe” (sound) using the rare kanji 聲 instead of the normal 声 (see for example “Endless Rain” by X Japan). You know its sound (no pun intended), but you can’t find it by typing in the IME because that kanji is archaic (even EDICT don’t list it). However, by drawing it you can find the kanji.

The third is for writing names. When IME don’t recognize a name, you can input it by drawing character per character.