差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
dokuwiki:localize [2007/07/29 12:14] osamudokuwiki:localize [2007/07/31 15:36] (現在) osamu
行 72: 行 72:
 ^D</code> ^D</code>
 のように、入力した文字が分かち書きされて表示されればOK。 のように、入力した文字が分かち書きされて表示されればOK。
 +
 +
  
  
行 163: 行 165:
 また、indexer.phpにwordlen()という関数があるが、これも同じくアジア圏の文字は1文字1単語とみなす処理が入っているので また、indexer.phpにwordlen()という関数があるが、これも同じくアジア圏の文字は1文字1単語とみなす処理が入っているので
 <code php> <code php>
-    if(preg_match('/'.IDX_ASIAN2.'/u',$w)) +function wordlen($w){ 
-        $l += ord($w) - 0xE1;  // Lead bytes from 0xE2-0xEF+    // $l = strlen($w); 
 + 
 +    $l = utf8_strlen($w); 
 + 
 +    //// If left alone, all chinese "words" will get put into w3.idx 
 +    //// So the "length" of a "word" is faked 
 +    //if(preg_match('/'.IDX_ASIAN2.'/u',$w)) 
 +    //    $l += ord($w) - 0xE1;  // Lead bytes from 0xE2-0xEF 
 + 
 +    return $l; 
 +}
 </code> </code>
-2行コメントアウトする。+と変更。 
 + 
 +それから、同じくindexer.php の idx_getIndexWordsSorted() 関数の中に、 
 +<code php> 
 +        if ($wlen < 3 && $wild == 0 && !is_numeric($xword)) continue; 
 +</code> 
 +という部分があるが、このままだと3文字より短い単語を検索できない。英語などではそれでよいのだが、日本語の場合1~2文字の単語も検索できないと困るので、これを 
 +<code php> 
 +        if (preg_match('/[^0-9A-Za-z]/u', $string) && $wlen < 3 && $wild == 0 && !is_numeric($xword)) continue; 
 +</code> 
 +と書き換える。 
  
 //2005-12-8 - Mecabのプロセスがハングアップして残ってしまうのを避けるために''stream_set_blocking()''を追加//\\  //2005-12-8 - Mecabのプロセスがハングアップして残ってしまうのを避けるために''stream_set_blocking()''を追加//\\ 
dokuwiki/localize.1185678861.txt.gz · 最終更新: 2007/07/29 12:14 by osamu
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0