The Amitabha Sutra, Online

So, one of my personal projects that I’ve had for over 2 years was to print a copy of the Amitabha Sutra (amidakyō 阿弥陀経 in Japanese) in order to complete the “liturgy” section of my Buddhist texts page. I finally completed the task this week.

Because the Amitabha Sutra is longer than other popular chants, it’s actually really hard to find a simple, straightforward copy of it for liturgical purposes. But for me, I’ve always liked it because it’s compact but pretty interesting, and still small enough to chant (takes me on average about 10 minutes) if I read aloud. The problem is that the versions online have typos, and use the Japanese-style romanization (Nihon-shiki) which is hard for Westerners to read. So, I finally decided to post my own copy with the intention of making it:

  • Carefully formatted for readability (so people can read as they chant).
  • Use Hepburn-style romanization which is easier for Westerners to read.
  • No errors or typos!
  • Each Chinese character would be shown with its romanized pronunciation.

Also, unlike my past efforts with smaller texts, I have tried and failed a few times to get it posted. Why?

Because in order to make it readable, you have to put HTML tags all over the place, and trying to do that with a huge volume of text, mixed with Chinese characters is pretty impractical.

So, being a computer technician, I had an idea this week how to do it.

First, I took a copy/pasted this text (in romanized Japanese) into a file on my computer. I spent time using the VI Editor to carefully search and replace text so that each word was properly spaced, romaji was converted to Hepburn-style, and typos fixed. Then I removed all the extra formatting copied over from the website.

Finally, I wrote this amateur Perl script to process that file:


use strict;
use warnings;

my $kyo;
my @text;
my $i;

open(SUTRA, "< $ARGV[0]") || die "$!\n";
chomp ($kyo = <SUTRA>);
close (SUTRA);

@text = split(/\s/, $kyo);

print "<table>\n";
print "<tr>\n";

for ($i=0; $i < scalar(@text); $i++) {

	print "<td>$text[$i]</td>";
	if ((($i+1) % 10 == 0)) {
	if ((($i+1) % 5 == 0) && (($i+1) % 10 == 5)) {
		print "<td>&nbsp;</td>";


print "</tr>\n";
print "</table>\n";

sub newline {
	print "</tr>\n";
	print "<tr>\n";
	print "<td> </td><td> </td><td> </td><td> </td><td> </td>
<td>&nbsp;</td><td> </td><td> </td><td> </td><td> </td><td> </td>\n";
	print "</tr>\n";
	print "<tr>\n";

(Apologies to Perl experts… it is a cheap script written in 15 minutes, and I don’t program much)

This would walk through the text, and print HTML tags around each word, spaces where I wanted them (after every 5th word, but not the 10th word), and print a new line after the 10th word. I spent 3 hours testing it over and over, but I finally got the results I wanted. Then I copy and pasted the HUGE output into this page here.

When I first tried this years ago, I tried to put HTML around the Chinese characters first, and hope to fill in the romaji later, but it was just too time-consuming. So, I got the idea to try the opposite: build the HTML around the text, and fill in the Chinese characters later. That way, people could use it for chanting right away, but for reference, the Chinese characters could be filled in later.

So, I have finished the first part: the sutra is now online for people to use. I am working to fill in the Chinese characters as fast as possible (Perl can’t parse kanji easily, at least I don’t know how), but this may take weeks or even months.

Anyhow, please enjoy and let me know if it is useful for you. Thanks!

Be the first to like this post.

One Comment on “The Amitabha Sutra, Online”

  1. arunlikhati says:

    Let me know if you find a Perl module that facilitates processing Chinese characters. I’m thinking of setting up a database for learning Chinese (that thing that I’ve been meaning to do, but never get around to doing), and a Perl interface would certainly be helpful!

Leave a Reply

Gravatar Logo
Twitter picture

You are commenting using your
Twitter account. (Log Out)

Facebook photo

You are commenting using your
Facebook account. (Log Out)

Connecting to %s