[ Main Page ]

検索 tips

全文検索の設定の仕方。

namazuを使う

Installing namazu

ディストリビューションによってデフォルトをキャッシュの位置が違うようです。Vine Linuxの場合、

./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man \
--localstatedir=/var --libexecdir=/home/httpd/cgi-bin
    

のようにするとよいでしょう。時々バグが見つかるので、注意が必要です。

Making index

インデックスを作るcronを日に一回走らせます。
#!/bin/sh
# /home/httpd/indexに/usr/share/namazu/templateを
# テンプレートとして/home/httpd/htmlの内容のインデックスを作成
mknmz -q -c -O /home/httpd/index --exclude="(squirrelmail|cdrom|tiki)" \
/home/httpd/html/ -T /usr/share/namazu/template
# インデックス更新だけでは使われない部分がたまるので
# ガベージコレクションを実行する
gcnmz -q /home/httpd/index
    

この時に注意するのは、対象となるディレクトリと、テンプレートのディレクトリです。 対象となるディレクトリは、文字通り、検索の対象とするディレクトリです。 テンプレートのディレクトリは、検索時に

Namazu による全文検索システム
現在、 2,276 の文書がインデックス化され、 36,146 個のキーワードが登録されています。
インデックスの最終更新日: 2005-01-21 
    

のように表示される部分などのhtmlファイルを含むディレクトリです。通常、 NMZ.body.ja NMZ.foot.ja NMZ.head.ja NMZ.result.normal.ja NMZ.result.short.ja NMZ.tips.jaのセットを言語の種類だけ持ちます。 命名規則は、NMZ.(種類).(言語名)です。.(言語名)の部分がないものは デフォルト(英語)ですが、後述する.namazurcでデフォルトの言語を変えることもできます。 例えば、NMZ.headの一部は以下のようになっています。

...
</head>
<body lang="en">
<h1>Namazu: a Full-Text Search Engine</h1>
<p>
This index contains <!-- FILE --> 0 <!-- FILE --> documents and
<!-- KEY --> 0 <!-- KEY --> keywords. 
</p>
<p>
<strong>Last modified: <!-- DATE --> date <!-- DATE --></strong>
</p>
...
    
インデックス作成時に、<!-- FILE --> 0 <!-- FILE -->などの部分は実際の 文字列で置き換えられてインデックス出力ディレクトリに
...
</head>
<body lang="en">
<h1>Namazu: a Full-Text Search Engine</h1>
<p>
This index contains <!-- FILE --> 2,276 <!-- FILE --> documents and
<!-- KEY --> 36,146 <!-- KEY --> keywords. 
</p>
<p>
<strong>Last modified: <!-- DATE --> 2005-01-21 <!-- DATE --></strong>
</p>
...
    

といった内容で出力されます。

cgi-binの設定

cgi-binでの設定では、.namazurcを以下のように項目を設定します。

...
Index         /home/httpd/index
Template      /home/httpd/index
...
    

HTMLページでの検索部分は、例えば、namazu.cgiがhttp://localhost/cgi-bin/namazu.cgi にあるとして、.namazurcを上の様に設定して、namazu.cgiとおなじディレクトリに置き、

<form method="GET" action="/cgi-bin/namazu.cgi">
<strong>ここの文書を検索</strong>
<INPUT TYPE="TEXT" NAME="key" SIZE="20" value="">
<INPUT TYPE="SUBMIT" NAME="submit"VALUE="Go">
<INPUT TYPE="HIDDEN" NAME="whence"VALUE="0">
</FORM>
    

のようなコードを書けば良いでしょう。

It's not true that those who can't do, teach (some of the best hackers I know
are professors), but it is true that there are a lot of things that those who
teach can't do. Research imposes constraining caste restrictions. In any
academic field there are topics that are ok to work on and others that aren't.
Unfortunately the distinction between acceptable and forbidden topics is
usually based on how intellectual the work sounds when described in research
papers, rather than how important it is for getting good results. The extreme
case is probably literature; people studying literature rarely say anything
that would be of the slightest use to those producing it.

Though the situation is better in the sciences, the overlap between the kind
of work you're allowed to do and the kind of work that yields good languages
is distressingly small. (Olin Shivers has grumbled eloquently about this.) For
example, types seem to be an inexhaustible source of research papers, despite
the fact that static typing seems to preclude true macros-- without which, in
my opinion, no language is worth using.

    -- Paul Graham
    -- "The Hundred-Year Language" ( http://www.paulgraham.com/hundred.html )

I disagree with your generalization that physicists are smarter than
professors of French Literature.

Try this thought experiment. A dictator takes over the US and sends all the
professors to re-education camps. The physicists are told they have to learn
how to write academic articles about French literature, and the French
literature professors are told they have to learn how to write original
physics papers. If they fail, they'll be shot. Which group is more worried?

We have some evidence here: the famous parody that physicist Alan Sokal got
published in Social Text. How long did it take him to master the art of
writing deep-sounding nonsense well enough to fool the editors? A couple
weeks?

What do you suppose would be the odds of a literary theorist getting a parody
of a physics paper published in a physics journal?

    -- Paul Graham
    -- Re: What You Can't Say ( http://www.paulgraham.com/resay.html )


Powered by UNIX fortune(6)
[ Main Page ]