NamazuのインデックスにWordが登録されない??
以前にNamazuを使った全文検索システムを構築しました。 → こちら
しかし、Wordがインデックスに登録されないという障害にでくわしてしまいました。原因をいろいろと
探っていたのですが、不明。
事前にOffice2003をインストール済みでしたが、もしかしたらNamazuのバージョンが古いのかな(2.0.12使用)
と思い、namazu2.0.14をインストールしてみました。しかし、結果は同じ
インデックスを作成しようとすると、wordに対しては「cannot start Word…」というエラーが出力されてしまいます。
エラーの内容からC:\namazu\share\namazu\win32\olemsmord.plの「$word=Win32::OLE->new
('Word.Application)」行の処理に失敗しているようです。これはPerlからWordにアクセスするという
処理ですが、この行が失敗しているようです。
そこで思ったのが、実はインストールしているパソコンには過去にOffice2002やOffice97、Office2007をインスト
ールしていたことがあって(今はOffice2003のみ)、それが関係しているのかなぁと漠然と思いました。
検証用のパソコンということもあってOSを再インストールしてOffice2003をインストールしました。
その後、namazu2.0.14をインストールすると、すんなりとWordもインデックスに登録されるようになりました。
以下が手順です。
用意するもの
ActivePerl-5.8.9.826-MSWin32-x86-290470
kakasi2.3.4.zip
xampp-win32-1.6.6a-installer
nmz2014beta.exe
手順1
ActivePerlをインストール
手順2
xamppをインストール。httpd.confを設定
手順3
kakasiをインストール
ここらへんは前回インストール時の記事 を参考にどうぞ
手順4
Namazuをインストール
手順5
パソコンを再起動
手順6
namazuの設定ファイルを編集する
EUCで保存可能なテキストエディタで「C:\namazu\etc\namazu\mknmzrc」を開く
赤字部分のコメントを外します。
#
# This is a Namazu configuration file for mknmz.
#
package conf; # Don't remove this line!
#===================================================================
#
# Administrator's email address
#
コメントを外す。管理者のアドレスに変更する
$ADDRESS = 'xxxxxx@gmail.com'
;
#===================================================================
#
# Regular Expression Patterns
#
#
# This pattern specifies HTML suffixes.
#
コメントを外す。HTMLファイルとして認識するファイルを定義
$HTML_SUFFIX = "html?|[ps]html|html\\.[a-z]{2}";
#
# 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
#
# 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.
#
コメントを外す。pngやjpegなどインデックス作成の対象にしないファイルを定義
$DENY_FILE = ".*\\.(gif|png|jpg|jpeg)|.*\\.tar\\.gz|core|.*\\.bak|.*~|\\..*|\x23.*";
#
# 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;
#
# The max text size for indexing. Files larger than this
# will be ignored.
#
$TEXT_SIZE_MAX = 600000;
#
# 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を上書保存します。
手順7
コマンドプロンプトから設定内容を確認する
mknmz -C
手順8
namazuの設定ファイルを編集する
EUCで保存可能なテキストエディタで「C:\namazu\etc\namazu\namazurc」を開く
赤字部分のコメントを外します。
# 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でインデックスを作成したディレクトリを指定
Index D:\namazu\index
##
## Template: Set the template directory containing
## NMZ.{head,foot,body,tips,result} files.
##
Template C:\namazu\share\namazu\template
#Template D:\namazu\template
##
## 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/
検索対象のファイルを格納したディレクトリ(D:\namazu\docs)をhttp://で始まる
URLに変換する設定。以下の設定でD:\namazu\docs/をhttp://127.0.0.1/search/docs/で
アクセスできるになる
Replace /D\|/namazu/docs/ http://127.0.0.1/search/docs/
##
## 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"
ファイルを上書保存します。
手順9
コマンドプロンプトから設定を確認する
namazu -C
手順10
インデックス用のフォルダとドキュメント格納用のフォルダを作成
D:\namazu\index
D:\namazu\docs
ドキュメント格納フォルダに検索したいWordやExcel、txtファイルを置いておく
手順11
コマンドプロンプトからインデックスを作成
mknmz -a -U -O D:\namazu\index D:\namazu\docs
手順12
コマンドプロンプトからテストを行う
namazu "test"
"test"を含むドキュメントの一覧が表示されればOK
手順13
C:\xampp\cgi-binにC:\namazu\libexec\namazu.cgi.exeをコピー
手順14
コマンドプロンプトから以下を実行
copy c:\namazu\etc\namazu\namazurc c:\xampp\cgi-bin\.namazurc
手順15
Web上で検索するための表示ページを作成する。
D:\namazu\indexにあるNMZ.head.jaとNMZ.body.ja、NMZ.foot.jaを1ファイルにまとめてsearch.htmlという
名前で保存(NMZ.head.ja → NMZ.body.ja → NMZ.foot.jaの順番)
ファイルをドキュメントルートに置く(C:\xampp\htdocs)
ブラウザからアクセスして、確認してみる
以上です。
Javascript自動化処理その3
今回も前回 に引き続き、IllustratorをJavascriptで自動化する処理の勉強です。
activeDocument.textFrames[x].paragraphs
現在開いているドキュメントのx番目のテキストフレームに含まれる段落
activeDocument.textFrames[x].paragraphs.length
現在開いているドキュメントのx番目のテキストフレームに含まれる段落の数
activeDocument.textFrames[x].lines
現在開いているドキュメントのx番目のテキストフレームに含まれる各行
activeDocument.textFrames[x].lines.length
現在開いているドキュメントのx番目のテキストフレームに含まれる各行の合計文字数
これらを使って文字あふれチェックをしてみます。
for(x=0;x<activeDocument.textFrames.length;x++){
txt=activeDocument.textFrames[x];
//テキストフレームの文字数から改行の数を除く(テキストフレームの合計文字数を取得)
charlength=txt.characters.length-txt.paragraphs.length+1;
linelength=0;
//テキストフレームに表示されている合計文字数を取得
for(j=0;j<txt.lines.length;j++){
//activeDocument.textFrames[x].lines[j].length(テキストフレームの1行の合計文字数)
linelength+=txt.lines[j].length;
}
//テキストフレームの合計文字数(charlength)と表示されている合計文字数(linelength)を比較
//合計文字数が異なっていれば、テキストフレームを選択状態にする
if(charlength>linelength){
txt.selected=true;
mozi_flg=1;
}
}
if(mozi_flg==0){
alert("文字あふれはありません。");
}else{
alert("文字あふれがあります。");
}
本の紹介
DTPを勉強中の方必見です。パンフレット、チラシなどをプロが教えるテクニックを使ってマスターして
いくことができます。初心者の方にわかりやすいようにわかりやすくできています。ただ、操作方法を
覚えるという本はたくさんありますが、この本の一番の魅力は「なぜこの操作をするのか?」という理屈
まで詳しく書かれています。操作方法を覚える(暗記のみ)だけの本ではすぐに忘れてしまいますが、この本は
なぜこうするのか?という理屈も知ることができるので、暗記ではなくて脳に記憶されるので効率的な
勉強ができます。
DTPデザイナー&オペレーターのためのIllustrator練習帳―サンプルを使ってマスターできる!CS3、CS2、CS対応
DTPデザイナー&オペレーターのためのInDesign練習帳―サンプルを使ってマスターできる!CS4、CS3、CS2、CS対応
DTPデザイナー&オペレーターのためのPhotoshop練習帳―サンプルを使ってマスターできる!CS3、CS2、CS対応
Javascriptを使った自動化処理その2
IllustratorCSでJavascriptを使った自動化処理の勉強中です。ちょっとまとめました。
activeDocument.selection
現在開いているIllustratorのドキュメントの中で選択しているオブジェクトの配列です。
以下のようにすると、ドキュメントで選択されているオブジェクトが配列として変数Objに格納されます。
Obj=activeDocument.selection;
例)ドキュメント上で「パス」と「テキストフレーム」の2つのオブジェクトを選択した状態で以下の
スクリプトを実行します。
Obj=activeDocument.selection;
alert(Obj[0]);
alert(Obj[1]);
実行結果
アラートダイアログボックスに[PathItem]と表示されます。「OK」をクリックすると
アラートダイアログボックスに[TextFrame]と表示されます。
activeDocument.textFrames
現在開いているドキュメント内のテキストフレームを示します。
activeDocument.textFrames.length
現在開いているドキュメント内のテキストフレームの数を示します。
例)ドキュメント内のすべてのテキストフレームを選択したい場合は以下のようにします。
for(i=0;i<activeDocument.textFrames.length;i++){
activeDocument.textFrames[i].selected=true;
}
※特定のオブジェクトを選択状態にしたい場合は、「selected」を付けて「true」にします。選択状態を
解除したい場合は、「false」にします。
activeDocument.textFrames[x].characters
現在開いているドキュメントのx番目のテキストフレーム内の文字全体を示します。
activeDocument.textFrames[x].characters.length
現在開いているドキュメントのテキストフレーム内の合計文字数を示します。
activeDocument.textFrames[x].characters[i]
現在開いているドキュメントのx番目のテキストフレーム内のi番目の文字を示します。
activeDocument.textFrames[x].characters[i].textFont
現在開いているドキュメントのx番目のテキストフレーム内のi番目の文字に設定されているフォントを示します。
activeDocument.textFrames[x].characters[i].verticalScale
現在開いているドキュメントのx番目のテキストフレーム内のi番目の文字に設定されている垂直比率を示します。
activeDocument.textFrames[x].characters[i].horizontalScale
現在開いているドキュメントのx番目のテキストフレーム内のi番目の文字に設定されている水平比率を示します。
例えばドキュメント内のすべてのテキストフレームの1文字ずつに設定されているフォントが
MS-明朝になっているかを確認し、別のフォントがあるテキストフレームを選択状態にしたい場合
msmincho=app.textFonts.getByName("MS-Mincho");
txt_length=activeDocument.textFrames.length;
for(i=0;i<txt_length;i++){
font_flg=0;
for(j=0;j<activeDocument.textFrames[i].characters.length;j++){
if(activeDocument.textFrames[i].characters[j].textFont!=msmincho){
font_flg=1;
err_flg=1;
}
}
if(font_flg==1){
activeDocument.textFrames[i].selected=true;
}
}
if(err_flg==0){
alert("書体はすべてMS-明朝です。");
}else{
alert("書体がMS-明朝ではありません。");
}
本の紹介
DTPを勉強中の方必見です。パンフレット、チラシなどをプロが教えるテクニックを使ってマスターして
いくことができます。初心者の方にわかりやすいようにわかりやすくできています。ただ、操作方法を
覚えるという本はたくさんありますが、この本の一番の魅力は「なぜこの操作をするのか?」という理屈
まで詳しく書かれています。操作方法を覚える(暗記のみ)だけの本ではすぐに忘れてしまいますが、この本は
なぜこうするのか?という理屈も知ることができるので、暗記ではなくて脳に記憶されるので効率的な
勉強ができます。
DTPデザイナー&オペレーターのためのIllustrator練習帳―サンプルを使ってマスターできる!CS3、CS2、CS対応
DTPデザイナー&オペレーターのためのInDesign練習帳―サンプルを使ってマスターできる!CS4、CS3、CS2、CS対応
DTPデザイナー&オペレーターのためのPhotoshop練習帳―サンプルを使ってマスターできる!CS3、CS2、CS対応