Skip to content
This repository has been archived by the owner on Oct 21, 2018. It is now read-only.

Commit

Permalink
Commit upstream source tree.
Browse files Browse the repository at this point in the history
  • Loading branch information
oknj committed Oct 8, 2014
0 parents commit df9a07b
Show file tree
Hide file tree
Showing 31 changed files with 3,970 additions and 0 deletions.
13 changes: 13 additions & 0 deletions COPYRIGHT.textsearch_ja
@@ -0,0 +1,13 @@
textsearch-ja
http://textsearch-ja.projects.postgresql.org/index-ja.html

Copyright (c) 2008-2009, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the NTT OSS Center nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 changes: 28 additions & 0 deletions Makefile
@@ -0,0 +1,28 @@
MODULE_big = textsearch_ja
DATA_built = textsearch_ja.sql
DATA = uninstall_textsearch_ja.sql
OBJS = textsearch_ja.o encoding_eucjp.o encoding_utf8.o pgut/pgut-be.o
REGRESS = init convert textsearch_ja
SHLIB_LINK = -lmecab

ifndef USE_PGXS
top_builddir = ../..
makefile_global = $(top_builddir)/src/Makefile.global
ifeq "$(wildcard $(makefile_global))" ""
USE_PGXS = 1 # use pgxs if not in contrib directory
endif
endif

ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = contrib/$(MODULE_big)
include $(makefile_global)
include $(top_srcdir)/contrib/contrib-global.mk
endif

# remove dependency to libxml2 and libxslt
LIBS := $(filter-out -lxml2, $(LIBS))
LIBS := $(filter-out -lxslt, $(LIBS))
55 changes: 55 additions & 0 deletions README.textsearch_ja
@@ -0,0 +1,55 @@
textsearch_ja - version 8.4.2 (2009-07-07)

日本語テキストの全文テキスト検索を行います。
PostgreSQL 8.3 で追加された組み込みテキスト検索を拡張するため、
英語文書の検索と同様の方法で、日本語文書を検索することができます。

詳しくは、doc/textsearch_ja.html もしくは
プロジェクトのホームページを参照してください。
http://textsearch-ja.projects.postgresql.org/index-ja.html

検索は形態素解析を利用した単語単位で行われます。
形態素解析には MeCab (http://mecab.sourceforge.net/) を使用しています。

■■■ ディレクトリ構成 ■■■

- dict : サンプルの類義語辞書ファイルです。
- doc : ドキュメント文書です。
- expected, sql : 動作確認用のリグレッション・テストです。

■■■ インストール ■■■

■ mecab-0.97 のインストール
./configure --enable-utf8-only
make
sudo make install

■ mecab-ipadic-2.7.0-20070801 のインストール
./configure --with-charset=utf8
make
sudo make install

■ OS 環境設定
export LD_LIBRARY_PATH=/usr/local/lib

(Windows の場合)
・HKEY_CURRENT_USER\Software\mecab
文字列 [mecabrc] = C:\msys\1.0\local\etc\mecabrc
・C:\msys\1.0\local\etc\mecabrc
dicdir = C:\msys\1.0\local\lib\mecab\dic\ipadic

■ contrib/textsearch_ja のインストール
make
sudo make install
psql -f textsearch_ja.sql

■ 辞書変換 と PostgreSQL の設定
DATABASE のエンコーディングと、MeCab の辞書のエンコーディングを
一致させる必要があります。

(UTF-8 を使う場合)
/usr/local/libexec/mecab/mecab-dict-index -f euc-jp -t utf-8
initdb --no-locale --encoding=utf8

----
Copyright (c) 2008-2009, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
3 changes: 3 additions & 0 deletions dict/english.syn
@@ -0,0 +1,3 @@
postgres pgsql
postgresql pgsql
postgre pgsql
19 changes: 19 additions & 0 deletions dict/install.sql
@@ -0,0 +1,19 @@
\echo NOTICE: Copy *.syn files into $PGDATA/shared/tsearch_data before install.

BEGIN;
-- Install japanese synonym dictionary
CREATE TEXT SEARCH DICTIONARY japanese_syn (
TEMPLATE = synonym,
SYNONYMS = japanese
);
ALTER TEXT SEARCH CONFIGURATION japanese
ALTER MAPPING FOR word, hword_part, hword WITH japanese_syn, simple;

-- Install english synonym dictionary
CREATE TEXT SEARCH DICTIONARY english_syn (
TEMPLATE = synonym,
SYNONYMS = english
);
ALTER TEXT SEARCH CONFIGURATION japanese
ALTER MAPPING FOR asciiword, hword_asciipart, asciihword WITH english_syn, english_stem;
COMMIT;
5 changes: 5 additions & 0 deletions dict/japanese.syn
@@ -0,0 +1,5 @@
インデクス index
インデックス index
ポスグレ pgsql
ポストグレス pgsql
バキューム vacuum
113 changes: 113 additions & 0 deletions doc/index-ja.html
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<link rel="icon" type="image/png" href="http://pgfoundry.org/images/elephant-icon.png" />
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>textsearch-ja: Project Home Page</title>
</head>

<body>
<center><img style="border: none; margin-left: auto; margin-right: auto; " src="http://pgfoundry.org/images/elephantSmall.png" height="75" width="75" />
<hr />
<h1>textsearch-ja ホームページへようこそ</h1>
<hr />
</center>
<p>
形態素解析 または N-gram を使用した、組み込み型の日本語全文検索です。
また、検索の他にも日本語を扱うためのユーティリティを提供しています。
</p>
<p>この textsearch-ja プロジェクトは <a href="http://www.postgresql.org">PostgreSQL</a> コミュニティによる <a href="http://pgfoundry.org">pgFoundry</a> の中の<a href="http://pgfoundry.org/projects/textsearch-ja">プロジェクト</a>です。</p>
<ul>
<li><a href="http://pgfoundry.org/frs/?group_id=1000298">ダウンロード</a> : ソースコードのほか、Windows 用バイナリもダウンロードできます。</li>
<li><a href="http://pgfoundry.org/tracker/?group_id=1000298">バグレポート</li></li>
<li><a href="http://pgfoundry.org/mail/?group_id=1000298">メーリングリスト</a> への参加</li>
</ul>
<div>
<a href="index.html">Here is an English page.</a>
</div>
<hr />

<p>
このプロジェクトでは「<a href="textsearch_ja.html">textsearch_ja</a>」と「<a href="textsearch_senna.html">textsearch_senna</a>」の2種類の全文検索インデックスがあります。
それぞれ特徴があるため、用途に応じて使い分けてください。
一般的には、文法的に整った文書を検索する場合には textsearch_ja (形態素解析) 、LIKE 演算子に近い結果を得たい場合には textsearch_senna (N-gram) が適しています。
</p>
<p>
EUDC モジュールは全文検索ではありませんが、PostgreSQL で外字領域を含む日本語文書を扱う際に役立つユーティリティです。
</p>

<h2 id="textsearch_ja">textsearch_ja : 形態素解析</h2>
<p><a href="textsearch_ja.html">textsearch_ja</a> は形態素解析を用いた全文検索機能です。
PostgreSQL 8.3 で追加された組み込みテキスト検索を拡張するため、
英語文書の検索と同様の方法で、日本語文書を検索することができます。
検索は形態素解析を利用した単語単位で行われます。
形態素解析には <a href="http://mecab.sourceforge.net/">MeCab</a> を使用しています。</p>
<p>利点として、GIN または GiST インデックスをベースにしているため、全文検索用のインデックスがリカバリ可能であることが挙げられます。
また、既に tsearch2 に対応している欧米言語を対象とした製品を大きく改変することなく、日本語対応できる強みがあります。</p>
</p>

<h2 id="textsearch_senna">textsearch_senna : N-gram</h2>
<p><a href="textsearch_senna.html">textsearch_senna</a> では N-gram ベースの全文検索を行います。
検索には、全文検索エンジン <a href="http://qwik.jp/senna/FrontPageJ.html">Senna</a> を使用しています。
</p>
<p>利点として、文字すべてをインデックス化するため LIKE 中間一致検索に近い結果を得ることができます。
また、既に tsearch2 互換のインタフェースを備えるため、少々の設定変更で textsearch-ja と textsearch_senna を切り替えて使用することができます。
ただし、クラッシュ・リカバリやアーカイブ・リカバリに対応していないことに注意してください。リカバリ後にインデックスの再作成を行う必要があります。
</p>

<h2 id="eudc">EUDC (End User Defined Character) : 外字対応文字コード</h2>
<p>
<a href="eudc.html">eudc</a> モジュールは、外字領域の文字コード変換をサポートしたエンコーディングです。
シフトSJIS (SJIS) や EUC_JP と、UTF-8 の変換において、外字領域の変換を追加します。
絵文字等の外字を扱う必要があり、かつクライアント・アプリケーションとデータベースで異なる文字コードを使う場合に有用です。
</p>

<h2 id="links">関連リンク</h2>
<ul>
<li>tsearch に対応したソフトウェア製品
<ul>
<li><a href="http://www.mediawiki.org/wiki/MediaWiki/ja">MediaWiki</a> : Wiki</li>
<li><a href="http://sylpheed.sraoss.jp/ja/">Sylph-Searcher</a> : メーラ Sylpheed 内の全文検索</li>
</ul>
</li>
<li>カンファレンスや勉強会での紹介
<ul>
<li><a href="http://www.slideshare.net/iakio/oscdo2009-textsearch">textsearch_jaで全文検索</a>
(石田朗雄 氏, <a href="http://www.ospn.jp/osc2009-do/modules/eguide/event.php?eid=19">オープンソースカンファレンス 2009 Hokkaido</a>)</li>
<li><a href="http://www.postgresql.jp/events/postgresql-conference-2008-program/#technical_2">PostgreSQL の全文検索</a>
(佐藤友章 氏, PostgreSQL Conference 2008)</li>
<li><a href="http://labo.e-2.co.jp/data/php-study34-pgsql.pdf">PostgreSQLで日本語全文検索</a> [PDF]
(わたなべかずひろ 氏, <a href="http://events.php.gr.jp/events/show/46">第34回PHP勉強会</a>)</li>
</ul>
</li>
<li>他の PostgreSQL 組み込み型の全文検索システム
<ul>
<li><a href="http://sourceforge.jp/projects/ludia/">Ludia</a>
: <a href="http://qwik.jp/senna/FrontPageJ.html">Senna</a> をエンジンとする全文検索システム</li>
<li><a href="http://pgestraier.projects.postgresql.org/">pgestraier</a>
: <a href="http://hyperestraier.sourceforge.net/index.ja.html">Hyper Estraier</a> をエンジンとする全文検索システム</li>
<li><a href="http://pgfoundry.org/projects/pgrast/">pgRast</a>
: <a href="http://projects.netlab.jp/rast/?FrontPage.ja">Rast</a> をエンジンとする全文検索システム</li>
</ul>
</li>
</ul>

<hr />
<p class="footer">Copyright (c) 2008-2009, NIPPON TELEGRAPH AND TELEPHONE CORPORATION</p>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-10244036-3");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
73 changes: 73 additions & 0 deletions doc/index.html
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="icon" type="image/png" href="http://pgfoundry.org/images/elephant-icon.png" />
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>textsearch-ja: Project Home Page</title>
</head>

<body>
<center><img style="border: none; margin-left: auto; margin-right: auto; " src="http://pgfoundry.org/images/elephantSmall.png" height="75" width="75" />
<hr />
<h1>Welcome to the textsearch-ja Project Home Page</h1>
<hr />
</center>
<p>Integrated Full-Text-Search for Japanese language using morphological analyze.</p>
<p>The textsearch-ja project is a <a href="http://www.postgresql.org">PostgreSQL</a> Community project that is a part of the <a href="http://pgfoundry.org">pgFoundry</a>.</p>
<p>The pgFoundry page for the project is at <a href="http://pgfoundry.org/projects/textsearch-ja">http://pgfoundry.org/projects/textsearch-ja</a>,
where you can find <a href="http://pgfoundry.org/frs/?group_id=1000298">downloads</a>, documentation, bug reports, mailing lists, and a whole lot more.</p>
<div>
<a href="index-ja.html">日本語のページはこちら。</a>
</div>
<hr />

<h2>Text search functions</h2>
<p>
(These functions are only useful for Japanese users...)
</p>

<h2>Other search functions</h2>
<h3>Web search compatible query (web_query)</h3>
<p>
textsearch uses &amp;, | and ! for AND, OR and NOT operators to control queries.
They are different compared with general web search queries.
The function web_query() convert space ' ', OR and hyphen '-' into tsquery operators.
</p>
<pre><code>=# SELECT to_tsquery('english', 'Relational Database');
ERROR: syntax error in tsquery: "Relational Database"

=# SELECT to_tsquery('english', web_query('Relational Database'));
to_tsquery
---------------------
'relat' & 'databas'
(1 row)</code></pre>

<p>
NOTICE: Presently, OR operator has higher priority than AND operator.
OR operator often has higher priority in general web searning.
</p>

<h2>Japanese analyzing functions</h2>
<p>
(These functions are only useful for Japanese users...)
</p>

<hr />
<p class="footer">Copyright (c) 2008-2009, NIPPON TELEGRAPH AND TELEPHONE CORPORATION</p>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-10244036-3");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
Binary file added doc/mecab-encoding.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions doc/style.css
@@ -0,0 +1,81 @@
body {
font-family:
Lucida Grande, Verdana, Arial, Helvetica,
'メイリオ',
'Meiryo',
'ヒラギノ角ゴ Pro W3',
'Hiragino Kaku Gothic Pro',
'Osaka',
'MS Pゴシック',
sans-serif;
color: #202020;
}

/* give the rule a bit of extra space (above and below), since its being used to divide
sections on some pages (project summary) */
HR { margin: 5px 0px 5px 0px }


h2, h3, h4, h5, h6 {
color: Black;
background: none;
padding-top: 0.5em;
padding-bottom: 0.17em;
border-bottom: 1px solid #aaaaaa;
}
H1 { font-size: x-large; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }
H2 { font-size: large; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }
H3 { padding-left: 1em; font-size: medium; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }
H4 { padding-left: 2em; font-size: small; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }
H5 { padding-left: 3em; font-size: x-small; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }
H6 { padding-left: 4em; font-size: xx-small; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }

pre {
font-family: courier,sans-serif;
background-color: #FBFBFD;
border: 1px dashed #7E7ECB;
color: black;
line-height: 1.1em; padding: 0.5em;
overflow: auto;
}

li {
line-height: 1.4em;
}

table {
background: #f9f9f9;
border: 1px solid #aaa;
border-collapse: collapse;
}

th, td {
border: 1px solid #aaa;
padding: 0.2em;
}

thead th {
background: #f2f2f2;
text-align: center;
}

tbody th {
background: #f2f2f2;
text-align: left;
}

div.index {
float:right;
border:thin solid black;
background-color: white;
padding-top: 0.2em;
padding-bottom: 0.2em;
padding-left: 1em;
padding-right: 1em;
margin-left: 0.5em;
}

p.footer {
text-align: right;
font-size: small;
}

0 comments on commit df9a07b

Please sign in to comment.