Namazuの設定はC:\namazu\etc\namazuにあるmknmzrcとnamazurcの2つの設定ファイルの内容を変更するだけです。それも基本的にはコメントアウトされている設定個所のコメント記号(#)を外すだけで動作します。インストール直後の状態だと、C:\namazu\etc\namazuに
mknmzrc
mknmzrc-sample
mknmzrc-sample.win32
namazurc
namazurc-sample
namazurc-sample.win32 |
の6つのファイルがあります。
mknmzrcはmknmzプログラムで検索用のインデックスを作成する際の動作環境を設定します。namazurcはnamazuコマンドで検索を実行する際の環境を設定します。mknmzは検索用のキーワードのインデックス(索引)をつくるプログラムです。Perlで記述されています。namazuはC言語で記述されています。
-sample、-sample.win32というファイルはいずれも名前の通り、mknmzrcとnamazurcのサンプルです。win32が付いているファイルがWindows用のサンプルです。もう一方はLinuxなどUNIX系OS用のサンプルです。(もっとも一部のディレクトリの記述が異なるだけで内容に大差はありません)
インストール直後の状態ではmknmzrcとmknmzrc-sample.win32、namazurcとnamazurc-sample.win32は同一の内容です。
まずmknmzrcの内容を変更しましょう。基本的にはコメントアウト(行頭に#をつけ、コメント扱いになっている)されている設定個所のコメント記号(#)を外し、設定を有効にするだけです。
以下に変更する前のdefaultの状態のmknmzrcを示し、変更個所を例示しておきます。
#
# This is a Namazu configuration
file for
mknmz.
#
package conf; # Don't remove
this line!
#===================================================================
#
# Administrator's email address
#
# $ADDRESS = 'webmaster@foo.bar.jp'; <--行頭の#を外し、あなたのメールアドレスに変更します
#===================================================================
#
# Regular Expression Patterns
#
#
# This pattern specifies HTML
suffixes.
#
# $HTML_SUFFIX = "html?|[ps]html|html\\.[a-z]{2}"; <--行頭の#を外します
$HTML_SUFFIXはhtmlやhtm、shtml、html.jaなどhtmlファイルとして認識するファイルを定義しています
#
# This pattern specifies file
names which
will be targeted.
# NOTE: It can be specified by
--allow=regex
option.
# Do NOT use `$' or `^' anchors.
# Case-insensitive.
#
# $ALLOW_FILE = ".*\\.(?:$HTML_SUFFIX)|.*\\.txt"
. # HTML, plain text <--行頭の#を外します。
# "|.*\\.gz|.*\\.Z|.*\\.bz2"
.
# Compressed files <--行頭の#を外します
# "|.*\\.pdf|.*\\.ps"
. # PDF,
PostScript <--行頭の#を外します
# "|.*\\.tex|.*\\.dvi"
. # TeX,
DVI <--行頭の#を外します
# "|.*\\.rpm|.*\\.deb"
. # RPM,
DEB <--行頭の#を外します
# "|.*\\.doc|.*\\.xls|.*\\.ppt"
. # Word, Excel, PowerPoint <--行頭の#を外します
# "|.*\\.j[sabf]w|.*\\.jtd"
. #
Ichitaro 4, 5, 6, 7, 8 <--行頭の#を外します
# "|\\d+|[-\\w]+\\.[1-9n]";
# Mail/News,
man <--行頭の#を外します
$ALLOW_FILEはインデックス作成の対象となるファイル形式を定義しています。gzやtex、rpmなどWindowsでは通常お目にかからない拡張子も含まれていますが、すべて#を外してしまっても特に問題はありません
#
# This pattern specifies file
names which
will NOT be targeted.
# NOTE: It can be specified by
--deny=regex
option.
# Do NOT use `$' or `^' anchors.
# Case-insensitive.
#
# $DENY_FILE = ".*\\.(gif|png|jpg|jpeg)|.*\\.tar\\.gz|core|.*\\.bak|.*~|\\..*|\x23.*"; <--行頭の#を外します
$DENY_FILEはjpegなどのイメージファイルやバックアップファイルなどインデックスを作成しないファイルを指定しています。
#
# This pattern specifies PATHNAMEs
which
will NOT be targeted.
# NOTE: Usually specified by
--exclude=regex
option.
#
# $EXCLUDE_PATH = undef; <--行頭の#を外します
#
# This pattern specifies file
names which
can be omitted
# in URI. e.g., 'index.html|index.htm|Default.html'
#
# NOTE: This is similar to Apache's
"DirectoryIndex"
directive.
#
# $DIRECTORY_INDEX = ""; <--行頭の#を外します
#
# This pattern specifies Mail/News's
fields
in its header which
# should be searchable. NOTE:
case-insensitive
#
# $REMAIN_HEADER = "From|Date|Message-ID"; <--行頭の#を外します
#
# This pattern specifies fields
which used
for field-specified
# searching. NOTE: case-insensitive
#
# $SEARCH_FIELD = "message-id|subject|from|date|uri|newsgroups|to|summary|size"; <--行頭の#を外します
#
# This pattern specifies meta
tags which
used for field-specified
# searching. NOTE: case-insensitive
#
# $META_TAGS = "keywords|description"; <--行頭の#を外します
#
# This pattern specifies aliases
for NMZ.field.*
files.
# NOTE: Editing NOT recommended.
#
# %FIELD_ALIASES = ('title' =>
'subject',
'author' => 'from'); <--行頭の#を外します
#
# This pattern specifies HTML
elements which
should be replaced with
# null string when removing them.
Normally,
the elements are replaced
# with a single space character.
#
# $NON_SEPARATION_ELEMENTS =
'A|TT|CODE|SAMP|KBD|VAR|B|STRONG|I|EM|CITE|FONT|U|'. <--行頭の#を外します
# 'STRIKE|BIG|SMALL|DFN|ABBR|ACRONYM|Q|SUB|SUP|SPAN|BDO'; <--行頭の#を外します
#===================================================================
#
# Critical Numbers
#
#
# The max size of files which
can be loaded
in memory at once.
# If you have much memory, you
can increase
the value.
# If you have less memory, you
can decrease
the value.
#
# $ON_MEMORY_MAX = 5000000; <--行頭の#を外します
#
# The max file size for indexing.
Files larger
than this
# will be ignored.
# NOTE: This value is usually
larger than
TEXT_SIZE_MAX because
# binary-formated files such
as PDF, Word
are larger.
#
# $FILE_SIZE_MAX = 2000000; <--行頭の#を外します
$FILE_SIZE_MAXはインデックス作成対象とするファイルの最大サイズをbyte単位で定義しています。defaultでは2000000byte=2Mbyteです。画像などを含むサイズが2Mbyte以上のファイルを扱う場合は適宜、数字を大きくしてください。$FILE_SIZE_MAXの制限に引っかかると、mknmzを実行中に「ファイルが巨大なので、無視しました」というメッセージが表示されます
#
# The max text size for indexing.
Files larger
than this
# will be ignored.
#
# $TEXT_SIZE_MAX = 600000; <--行頭の#を外します
$TEXT_SIZE_MAXはインデックス作成対象とするファイルから抽出したtextの最大サイズをbyte単位で定義しています。defaultでは600000byte=600Kbyteです。上の$FILE_SIZE_MAXのサイズ制限をクリアしているのに「ファイルが巨大なので、無視しました」というメッセージが表示される場合は$TEXT_SIZE_MAXの制限に引っかかっていることも考えられます。適宜、サイズを大きくしてみてください。
#
# The max length of a word. the
word longer
than this will be ignored.
#
# $WORD_LENG_MAX = 128; <--行頭の#を外します
#
# Weights for HTML elements which
are used
for term weightning.
#
# %Weight = <--行頭の#を外します
# ( <--行頭の#を外します
# 'html' => { <--行頭の#を外します
# 'title' => 16, <--行頭の#を外します
# 'h1' => 8, <--行頭の#を外します
# 'h2' => 7, <--行頭の#を外します
# 'h3' => 6, <--行頭の#を外します
# 'h4' => 5, <--行頭の#を外します
# 'h5' => 4, <--行頭の#を外します
# 'h6' => 3, <--行頭の#を外します
# 'a' => 4, <--行頭の#を外します
# 'strong' => 2, <--行頭の#を外します
# 'em' => 2, <--行頭の#を外します
# 'kbd' => 2, <--行頭の#を外します
# 'samp' => 2, <--行頭の#を外します
# 'var' => 2, <--行頭の#を外します
# 'code' => 2, <--行頭の#を外します
# 'cite' => 2, <--行頭の#を外します
# 'abbr' => 2, <--行頭の#を外します
# 'acronym'=> 2, <--行頭の#を外します
# 'dfn' => 2, <--行頭の#を外します
# }, <--行頭の#を外します
# 'metakey' => 32, # for <meta
name="keywords"
content="foo bar"> <--行頭の#を外します
# 'headers' => 8, # for Mail/News'
headers <--行頭の#を外します
# ); <--行頭の#を外します
#
# The max length of a HTML-tagged
string
which can be processed for
# term weighting.
# NOTE: There are not a few people
has a
bad manner using
# <h[1-6]> for changing
a font size.
#
# $INVALID_LENG = 128; <--行頭の#を外します
#
# The max length of a field.
# This MUST be smaller than libnamazu.h's
BUFSIZE (usually 1024).
#
# $MAX_FIELD_LENGTH = 200; <--行頭の#を外します
#===================================================================
#
# Softwares for handling a Japanese
text
#
#
# Network Kanji Filter nkf v1.62
or later
#
# $NKF = "module_nkf"; <--行頭の#を外します
#
# KAKASI
#
# $KAKASI = "module_kakasi
-ieuc -oeuc
-w"; <--行頭の#を外します
#
# ChaSen 1.51 or later (simple
wakatigaki)
#
# $CHASEN = "chasen -j -F
'\%m '";
#
# ChaSen 1.51 or later (with
noun words extraction)
#
# $CHASEN_NOUN = "chasen
-j -F '\%m
%H\\n'";
#
# Default Japanese processer:
KAKASI or ChaSen.
#
# $WAKATI = $KAKASI; <--行頭の#を外します
#===================================================================
#
# Directories
#
$LIBDIR = 'C:/namazu/share/namazu/pl';
$FILTERDIR = 'C:/namazu/share/namazu/filter';
$TEMPLATEDIR = 'C:/namazu/share/namazu/template';
1;
|
必要な変更をしたらmknmzrcを上書き保存します。
MS-DOSプロンプトで設定を確認するオプション-C(大文字です)をつけて、mknmzを実行してみます。次のような情報が表示されれば、設定は基本的に問題ないでしょう。なお、表示される対応メディアタイプは環境によって異なります。Word、Excel、Power
PointなどはNamazuをインストールする前にPCに導入されていないと対応メディアタイプに含まれません。一太郎については、Namazuは標準ではWordの文書コンバータの機能を使ってインデックスを作成しますが、Wordを使用しない方法もあります。別に紹介します。PDFは別にpdftotextというツールをインストールする必要があるので、標準の状態では対応メディアタイプに表示されません。
C:\WINDOWS>mknmz -C
読み込んだ設定ファイル: C:/namazu/etc/namazu/mknmzrc
システム: MSWin32
Namazu: 2.0.12
Perl: 5.006001
NKF: module_nkf
KAKASI: module_kakasi -ieuc -oeuc
-w
わかち書き: module_kakasi -ieuc
-oeuc -w
メッセージの言語: ja_JP.SJIS
言語: ja_JP.SJIS
文字コード: sjis
CONFDIR: C:/namazu/etc/namazu
LIBDIR: C:/namazu/share/namazu/pl
FILTERDIR: C:/namazu/share/namazu/filter
TEMPLATEDIR: C:/namazu/share/namazu/template
対応メディアタイプ:
application/excel
application/ichitaro4
application/ichitaro5
application/ichitaro6
application/ichitaro7
application/msword
application/pdf
application/powerpoint
application/rtf
application/x-gzip
application/x-js-taro
message/news
message/rfc822
text/hnf
text/html
text/html; x-type=mhonarc
text/plain
text/plain; x-type=rfc
text/x-hdml |
namazurcはnamazuコマンドの動作に関する内容を記述します。Search-S
for namazuを使ってLocalのPC内の文書を検索する場合は特に内容を書き換える必要はありません。通常、namazurcの設定がが必要になるのはapacheなどWeb
ServerでNamazuをCGI(namazu.cgi.exe)として動作させる際にnamazurcをドット付きの.namazurcにリネームして/cgi-binディレクトリなどに置いて使用するケースです。
詳細は「Web Serverで動作させよう」の項目で説明します。ここでは簡単に触れておきます。
# This is a Namazu configuration file for
namazu or namazu.cgi.
#
# Originally, this file is named
'namazurc-sample'.
so you should
# copy this to 'namazurc' to
make the file
effective.
#
# Each item is must be separated
by one or
more SPACE or TAB characters.
# You can use a double-quoted
string for
represanting a string which
# contains SPACE or TAB characters
like "foo
bar baz".
##
## Index: Specify the default
directory.
##
Index C:\namazu\var\namazu\index <--mknmzでインデックスを作成したディレクトリを指定します
##
## Template: Set the template
directory containing
## NMZ.{head,foot,body,tips,result}
files.
##
#Template C:\namazu\share\namazu\template <--行頭のコメント記号(#)を外します。検索結果などを表示するためのtemplateファイルの置き場所を指定します。mknmzが生成する標準のtemplateを使用する場合はIndexと同じディレクトリを指定しておきます
##
## Replace: Replace TARGET with
REPLACEMENT
in URIs in search
## results.
##
## TARGET is specified by Ruby's
perl-like
regular expressions.
## You can caputure sub-strings
in TARGET
by surrounding them
## with `(' and `)'and use them
later as
backreferences by
## \1, \2, \3,... \9.
##
## To use meta characters literally
such
as `*', `+', `?', `|',
## `[', `]', `{', `}', `(', `)',
escape them
with `\'.
##
## e.g.,
##
## Replace /home/foo/public_html/
http://www.foobar.jp/~foo/
## Replace /home/(.*)/public_html/
http://www.foobar.jp/\1/
## Replace /C\|/foo/ http://www.foobar.jp/
##
## If you do not want to do the
processing
on command line use,
## run namazu with -U option.
##
## You can specify more than
one Replace
rules but the only
## first-matched rule are applied.
##
#Replace /home/foo/public_html/
http://www.foo.bar.jp/~foo/ <--行頭のコメント記号(#)を外します。このReplaceがnamazurcの肝です。検索対象の文書を置いたLocalのPCのディレクトリをhttp://で始まるURLに置き換える動作をします。例えばCドライブのdocsフォルダ(C:\docs)をhttp://yourdomein.co.jp/docs/にリプレースしたい場合、Replace
/C\|/docs/ http://yourdomein.co.jp/docs/と記述します。ディレクトリの階層の記述方法がUNIX流のスラッシュ(/)になっているのに注意してください
##
## Logging: Set OFF to turn off
keyword logging
to NMZ.slog.
## Default is ON.
##
#Logging off
##
## Lang: Set the locale code
such as `ja_JP.eucJP',
`ja_JP.SJIS',
## `de', etc. This directive
works only if
the environment
## variable LANG is not set because
the directive
is mainly
## intended for CGI use. On the
shell, You
can set
## environemtnt variable LANG
instead of
using the directive.
##
## If you set `de' to it, namazu.cgi
use
## NMZ.(head|foot|body|tips|results).de
for
displaying results
## and use a proper message catalog
for `de'.
##
Lang ja_JP.SJIS
##
## Scoring: Set the scoring method
"tfidf"
or "simple".
##
#Scoring tfidf <--行頭のコメント記号(#)を外します。
##
## EmphasisTags: Set the pair
of html elements
which is used in
## keyword emphasizing for search
results.
##
#EmphasisTags "<strong
class=\"keyword\">"
"</strong>" <--行頭のコメント記号(#)を外します。
##
## MaxHit: Set the maximum number
of documents
which can be
## handled in query operation.
If documents
matching a
## query exceed the value, they
will be ignored.
##
#MaxHit 10000 <--行頭のコメント記号(#)を外します。
##
## MaxMatch: Set the maximum
number of words
which can be
## handled in regex/prefix/inside/suffix
query. If documents
## matching a query exceed the
value, they
will be ignored.
##
#MaxMatch 1000 <--行頭のコメント記号(#)を外します。
##
## ContentType: Set "Content-Type"
header output. If you want to
## use non-HTML template files,
set it suitably.
#ContentType "text/x-hdml" <--この行のコメント記号は外さないようにしましょう。これを外すと、namazu.cgi.exeが出力するファイルがhdml(携帯端末向けのコンテンツ記述言語)形式になり、検索結果がうまく表示できなかったり、「ファイルのダウンロード」になってしまいます。
|
namazurcの設定を確認するにはMS-DOSプロンプトでnamazu
-Cを実行します。
C:\WINDOWS>namazu -C
読み込んだ設定ファイル: C:\namazu\etc\namazu\namazurc
--
インデックス (Index): C:\namazu\var\namazu\index
ログの記録 (Logging): off
使用する言語 (Lang): ja_JP.SJIS
スコア計算 (Scoring): tfidf
テンプレート (Template): C:\namazu\var\namazu\index
ヒット件数の上限 (MaxHit): 10000
一致する語の上限 (MaxMatch):
1000
強調タグ (EmphasisTags): <strong
class="keyword">
</strong> |
|