1<?php 2/** 3 * Functions to create the fulltext search index 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9if(!defined('DOKU_INC')) die('meh.'); 10 11// set the minimum token length to use in the index (note, this doesn't apply to numeric tokens) 12if (!defined('IDX_MINWORDLENGTH')) define('IDX_MINWORDLENGTH',2); 13 14// Asian characters are handled as words. The following regexp defines the 15// Unicode-Ranges for Asian characters 16// Ranges taken from http://en.wikipedia.org/wiki/Unicode_block 17// I'm no language expert. If you think some ranges are wrongly chosen or 18// a range is missing, please contact me 19define('IDX_ASIAN1','[\x{0E00}-\x{0E7F}]'); // Thai 20define('IDX_ASIAN2','['. 21 '\x{2E80}-\x{3040}'. // CJK -> Hangul 22 '\x{309D}-\x{30A0}'. 23 '\x{30FD}-\x{31EF}\x{3200}-\x{D7AF}'. 24 '\x{F900}-\x{FAFF}'. // CJK Compatibility Ideographs 25 '\x{FE30}-\x{FE4F}'. // CJK Compatibility Forms 26 ']'); 27define('IDX_ASIAN3','['. // Hiragana/Katakana (can be two characters) 28 '\x{3042}\x{3044}\x{3046}\x{3048}'. 29 '\x{304A}-\x{3062}\x{3064}-\x{3082}'. 30 '\x{3084}\x{3086}\x{3088}-\x{308D}'. 31 '\x{308F}-\x{3094}'. 32 '\x{30A2}\x{30A4}\x{30A6}\x{30A8}'. 33 '\x{30AA}-\x{30C2}\x{30C4}-\x{30E2}'. 34 '\x{30E4}\x{30E6}\x{30E8}-\x{30ED}'. 35 '\x{30EF}-\x{30F4}\x{30F7}-\x{30FA}'. 36 ']['. 37 '\x{3041}\x{3043}\x{3045}\x{3047}\x{3049}'. 38 '\x{3063}\x{3083}\x{3085}\x{3087}\x{308E}\x{3095}-\x{309C}'. 39 '\x{30A1}\x{30A3}\x{30A5}\x{30A7}\x{30A9}'. 40 '\x{30C3}\x{30E3}\x{30E5}\x{30E7}\x{30EE}\x{30F5}\x{30F6}\x{30FB}\x{30FC}'. 41 '\x{31F0}-\x{31FF}'. 42 ']?'); 43define('IDX_ASIAN', '(?:'.IDX_ASIAN1.'|'.IDX_ASIAN2.'|'.IDX_ASIAN3.')'); 44 45/** 46 * Measure the length of a string. 47 * Differs from strlen in handling of asian characters. 48 * 49 * @author Tom N Harris <tnharris@whoopdedo.org> 50 */ 51function wordlen($w){ 52 $l = strlen($w); 53 // If left alone, all chinese "words" will get put into w3.idx 54 // So the "length" of a "word" is faked 55 if(preg_match('/'.IDX_ASIAN2.'/u',$w)) 56 $l += ord($w) - 0xE1; // Lead bytes from 0xE2-0xEF 57 return $l; 58} 59 60/** 61 * Write a list of strings to an index file. 62 * 63 * @author Tom N Harris <tnharris@whoopdedo.org> 64 */ 65function idx_saveIndex($pre, $wlen, &$idx){ 66 global $conf; 67 $fn = $conf['indexdir'].'/'.$pre.$wlen; 68 $fh = @fopen($fn.'.tmp','w'); 69 if(!$fh) return false; 70 fwrite($fh,join('', $idx)); 71 fclose($fh); 72 if(isset($conf['fperm'])) chmod($fn.'.tmp', $conf['fperm']); 73 io_rename($fn.'.tmp', $fn.'.idx'); 74 return true; 75} 76 77/** 78 * Append a given line to an index file. 79 * 80 * @author Andreas Gohr <andi@splitbrain.org> 81 */ 82function idx_appendIndex($pre, $wlen, $line){ 83 global $conf; 84 $fn = $conf['indexdir'].'/'.$pre.$wlen; 85 $fh = @fopen($fn.'.idx','a'); 86 if(!$fh) return false; 87 fwrite($fh,$line); 88 fclose($fh); 89 return true; 90} 91 92/** 93 * Read the list of words in an index (if it exists). 94 * 95 * @author Tom N Harris <tnharris@whoopdedo.org> 96 */ 97function idx_getIndex($pre, $wlen){ 98 global $conf; 99 $fn = $conf['indexdir'].'/'.$pre.$wlen.'.idx'; 100 if(!@file_exists($fn)) return array(); 101 return file($fn); 102} 103 104/** 105 * Create an empty index file if it doesn't exist yet. 106 * 107 * FIXME: This function isn't currently used. It will probably be removed soon. 108 * 109 * @author Tom N Harris <tnharris@whoopdedo.org> 110 */ 111function idx_touchIndex($pre, $wlen){ 112 global $conf; 113 $fn = $conf['indexdir'].'/'.$pre.$wlen.'.idx'; 114 if(!@file_exists($fn)){ 115 touch($fn); 116 if($conf['fperm']) chmod($fn, $conf['fperm']); 117 } 118} 119 120/** 121 * Read a line ending with \n. 122 * Returns false on EOF. 123 * 124 * @author Tom N Harris <tnharris@whoopdedo.org> 125 */ 126function _freadline($fh) { 127 if (feof($fh)) return false; 128 $ln = ''; 129 while (($buf = fgets($fh,4096)) !== false) { 130 $ln .= $buf; 131 if (substr($buf,-1) == "\n") break; 132 } 133 if ($ln === '') return false; 134 if (substr($ln,-1) != "\n") $ln .= "\n"; 135 return $ln; 136} 137 138/** 139 * Write a line to an index file. 140 * 141 * @author Tom N Harris <tnharris@whoopdedo.org> 142 */ 143function idx_saveIndexLine($pre, $wlen, $idx, $line){ 144 global $conf; 145 if(substr($line,-1) != "\n") $line .= "\n"; 146 $fn = $conf['indexdir'].'/'.$pre.$wlen; 147 $fh = @fopen($fn.'.tmp','w'); 148 if(!$fh) return false; 149 $ih = @fopen($fn.'.idx','r'); 150 if ($ih) { 151 $ln = -1; 152 while (($curline = fgets($ih)) !== false) { 153 if (++$ln == $idx) { 154 fwrite($fh, $line); 155 } else { 156 fwrite($fh, $curline); 157 } 158 } 159 if ($idx > $ln) { 160 fwrite($fh,$line); 161 } 162 fclose($ih); 163 } else { 164 fwrite($fh,$line); 165 } 166 fclose($fh); 167 if($conf['fperm']) chmod($fn.'.tmp', $conf['fperm']); 168 io_rename($fn.'.tmp', $fn.'.idx'); 169 return true; 170} 171 172/** 173 * Read a single line from an index (if it exists). 174 * 175 * @author Tom N Harris <tnharris@whoopdedo.org> 176 */ 177function idx_getIndexLine($pre, $wlen, $idx){ 178 global $conf; 179 $fn = $conf['indexdir'].'/'.$pre.$wlen.'.idx'; 180 if(!@file_exists($fn)) return ''; 181 $fh = @fopen($fn,'r'); 182 if(!$fh) return ''; 183 $ln = -1; 184 while (($line = fgets($fh)) !== false) { 185 if (++$ln == $idx) break; 186 } 187 fclose($fh); 188 return "$line"; 189} 190 191/** 192 * Split a page into words 193 * 194 * Returns an array of word counts, false if an error occurred. 195 * Array is keyed on the word length, then the word index. 196 * 197 * @author Andreas Gohr <andi@splitbrain.org> 198 * @author Christopher Smith <chris@jalakai.co.uk> 199 */ 200function idx_getPageWords($page){ 201 global $conf; 202 $swfile = DOKU_INC.'inc/lang/'.$conf['lang'].'/stopwords.txt'; 203 if(@file_exists($swfile)){ 204 $stopwords = file($swfile); 205 }else{ 206 $stopwords = array(); 207 } 208 209 $body = ''; 210 $data = array($page, $body); 211 $evt = new Doku_Event('INDEXER_PAGE_ADD', $data); 212 if ($evt->advise_before()) $data[1] .= rawWiki($page); 213 $evt->advise_after(); 214 unset($evt); 215 216 list($page,$body) = $data; 217 218 $body = strtr($body, "\r\n\t", ' '); 219 $tokens = explode(' ', $body); 220 $tokens = array_count_values($tokens); // count the frequency of each token 221 222 // ensure the deaccented or romanised page names of internal links are added to the token array 223 // (this is necessary for the backlink function -- there maybe a better way!) 224 if ($conf['deaccent']) { 225 $links = p_get_metadata($page,'relation references'); 226 227 if (!empty($links)) { 228 $tmp = join(' ',array_keys($links)); // make a single string 229 $tmp = strtr($tmp, ':', ' '); // replace namespace separator with a space 230 $link_tokens = array_unique(explode(' ', $tmp)); // break into tokens 231 232 foreach ($link_tokens as $link_token) { 233 if (isset($tokens[$link_token])) continue; 234 $tokens[$link_token] = 1; 235 } 236 } 237 } 238 239 $words = array(); 240 foreach ($tokens as $word => $count) { 241 $arr = idx_tokenizer($word,$stopwords); 242 $arr = array_count_values($arr); 243 foreach ($arr as $w => $c) { 244 $l = wordlen($w); 245 if(isset($words[$l])){ 246 $words[$l][$w] = $c * $count + (isset($words[$l][$w]) ? $words[$l][$w] : 0); 247 }else{ 248 $words[$l] = array($w => $c * $count); 249 } 250 } 251 } 252 253 // arrive here with $words = array(wordlen => array(word => frequency)) 254 255 $word_idx_modified = false; 256 257 $index = array(); //resulting index 258 foreach (array_keys($words) as $wlen){ 259 $word_idx = idx_getIndex('w',$wlen); 260 foreach ($words[$wlen] as $word => $freq) { 261 $wid = array_search("$word\n",$word_idx); 262 if(!is_int($wid)){ 263 $wid = count($word_idx); 264 $word_idx[] = "$word\n"; 265 $word_idx_modified = true; 266 } 267 if(!isset($index[$wlen])) 268 $index[$wlen] = array(); 269 $index[$wlen][$wid] = $freq; 270 } 271 272 // save back word index 273 if($word_idx_modified && !idx_saveIndex('w',$wlen,$word_idx)){ 274 trigger_error("Failed to write word index", E_USER_ERROR); 275 return false; 276 } 277 } 278 279 return $index; 280} 281 282/** 283 * Adds/updates the search for the given page 284 * 285 * This is the core function of the indexer which does most 286 * of the work. This function needs to be called with proper 287 * locking! 288 * 289 * @author Andreas Gohr <andi@splitbrain.org> 290 */ 291function idx_addPage($page){ 292 global $conf; 293 294 // load known documents 295 $page_idx = idx_getIndex('page',''); 296 297 // get page id (this is the linenumber in page.idx) 298 $pid = array_search("$page\n",$page_idx); 299 if(!is_int($pid)){ 300 $pid = count($page_idx); 301 // page was new - write back 302 if (!idx_appendIndex('page','',"$page\n")){ 303 trigger_error("Failed to write page index", E_USER_ERROR); 304 return false; 305 } 306 } 307 unset($page_idx); // free memory 308 309 idx_saveIndexLine('title', '', $pid, p_get_first_heading($page, false)); 310 311 $pagewords = array(); 312 // get word usage in page 313 $words = idx_getPageWords($page); 314 if($words === false) return false; 315 316 if(!empty($words)) { 317 foreach(array_keys($words) as $wlen){ 318 $index = idx_getIndex('i',$wlen); 319 foreach($words[$wlen] as $wid => $freq){ 320 if($wid<count($index)){ 321 $index[$wid] = idx_updateIndexLine($index[$wid],$pid,$freq); 322 }else{ 323 // New words **should** have been added in increasing order 324 // starting with the first unassigned index. 325 // If someone can show how this isn't true, then I'll need to sort 326 // or do something special. 327 $index[$wid] = idx_updateIndexLine('',$pid,$freq); 328 } 329 $pagewords[] = "$wlen*$wid"; 330 } 331 // save back word index 332 if(!idx_saveIndex('i',$wlen,$index)){ 333 trigger_error("Failed to write index", E_USER_ERROR); 334 return false; 335 } 336 } 337 } 338 339 // Remove obsolete index entries 340 $pageword_idx = trim(idx_getIndexLine('pageword','',$pid)); 341 if ($pageword_idx !== '') { 342 $oldwords = explode(':',$pageword_idx); 343 $delwords = array_diff($oldwords, $pagewords); 344 $upwords = array(); 345 foreach ($delwords as $word) { 346 if($word=='') continue; 347 list($wlen,$wid) = explode('*',$word); 348 $wid = (int)$wid; 349 $upwords[$wlen][] = $wid; 350 } 351 foreach ($upwords as $wlen => $widx) { 352 $index = idx_getIndex('i',$wlen); 353 foreach ($widx as $wid) { 354 $index[$wid] = idx_updateIndexLine($index[$wid],$pid,0); 355 } 356 idx_saveIndex('i',$wlen,$index); 357 } 358 } 359 // Save the reverse index 360 $pageword_idx = join(':',$pagewords)."\n"; 361 if(!idx_saveIndexLine('pageword','',$pid,$pageword_idx)){ 362 trigger_error("Failed to write word index", E_USER_ERROR); 363 return false; 364 } 365 366 return true; 367} 368 369/** 370 * Write a new index line to the filehandle 371 * 372 * This function writes an line for the index file to the 373 * given filehandle. It removes the given document from 374 * the given line and readds it when $count is >0. 375 * 376 * @deprecated - see idx_updateIndexLine 377 * @author Andreas Gohr <andi@splitbrain.org> 378 */ 379function idx_writeIndexLine($fh,$line,$pid,$count){ 380 fwrite($fh,idx_updateIndexLine($line,$pid,$count)); 381} 382 383/** 384 * Modify an index line with new information 385 * 386 * This returns a line of the index. It removes the 387 * given document from the line and readds it if 388 * $count is >0. 389 * 390 * @author Tom N Harris <tnharris@whoopdedo.org> 391 * @author Andreas Gohr <andi@splitbrain.org> 392 */ 393function idx_updateIndexLine($line,$pid,$count){ 394 $line = trim($line); 395 $updated = array(); 396 if($line != ''){ 397 $parts = explode(':',$line); 398 // remove doc from given line 399 foreach($parts as $part){ 400 if($part == '') continue; 401 list($doc,$cnt) = explode('*',$part); 402 if($doc != $pid){ 403 $updated[] = $part; 404 } 405 } 406 } 407 408 // add doc 409 if ($count){ 410 $updated[] = "$pid*$count"; 411 } 412 413 return join(':',$updated)."\n"; 414} 415 416/** 417 * Get the list of lenghts indexed in the wiki 418 * 419 * Read the index directory or a cache file and returns 420 * a sorted array of lengths of the words used in the wiki. 421 * 422 * @author YoBoY <yoboy.leguesh@gmail.com> 423 */ 424function idx_listIndexLengths() { 425 global $conf; 426 // testing what we have to do, create a cache file or not. 427 if ($conf['readdircache'] == 0) { 428 $docache = false; 429 } else { 430 clearstatcache(); 431 if (@file_exists($conf['indexdir'].'/lengths.idx') and (time() < @filemtime($conf['indexdir'].'/lengths.idx') + $conf['readdircache'])) { 432 if (($lengths = @file($conf['indexdir'].'/lengths.idx', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ) !== false) { 433 $idx = array(); 434 foreach ( $lengths as $length) { 435 $idx[] = (int)$length; 436 } 437 return $idx; 438 } 439 } 440 $docache = true; 441 } 442 443 if ($conf['readdircache'] == 0 or $docache ) { 444 $dir = @opendir($conf['indexdir']); 445 if($dir===false) 446 return array(); 447 $idx[] = array(); 448 while (($f = readdir($dir)) !== false) { 449 if (substr($f,0,1) == 'i' && substr($f,-4) == '.idx'){ 450 $i = substr($f,1,-4); 451 if (is_numeric($i)) 452 $idx[] = (int)$i; 453 } 454 } 455 closedir($dir); 456 sort($idx); 457 // we save this in a file. 458 if ($docache === true) { 459 $handle = @fopen($conf['indexdir'].'/lengths.idx','w'); 460 @fwrite($handle, implode("\n",$idx)); 461 @fclose($handle); 462 } 463 return $idx; 464 } 465 466 return array(); 467} 468 469/** 470 * Get the word lengths that have been indexed. 471 * 472 * Reads the index directory and returns an array of lengths 473 * that there are indices for. 474 * 475 * @author YoBoY <yoboy.leguesh@gmail.com> 476 */ 477function idx_indexLengths(&$filter){ 478 global $conf; 479 $idx = array(); 480 if (is_array($filter)){ 481 // testing if index files exists only 482 foreach ($filter as $key => $value) { 483 if (@file_exists($conf['indexdir']."/i$key.idx")) { 484 $idx[] = $key; 485 } 486 } 487 } else { 488 $lengths = idx_listIndexLengths(); 489 foreach ( $lengths as $key => $length) { 490 // we keep all the values equal or superior 491 if ((int)$length >= (int)$filter) { 492 $idx[] = $length; 493 } 494 } 495 } 496 return $idx; 497} 498 499/** 500 * Find the the index number of each search term. 501 * 502 * This will group together words that appear in the same index. 503 * So it should perform better, because it only opens each index once. 504 * Actually, it's not that great. (in my experience) Probably because of the disk cache. 505 * And the sorted function does more work, making it slightly slower in some cases. 506 * 507 * @param array $words The query terms. Words should only contain valid characters, 508 * with a '*' at either the beginning or end of the word (or both) 509 * @param arrayref $result Set to word => array("length*id" ...), use this to merge the 510 * index locations with the appropriate query term. 511 * @return array Set to length => array(id ...) 512 * 513 * @author Tom N Harris <tnharris@whoopdedo.org> 514 */ 515function idx_getIndexWordsSorted($words,&$result){ 516 // parse and sort tokens 517 $tokens = array(); 518 $tokenlength = array(); 519 $tokenwild = array(); 520 foreach($words as $word){ 521 $result[$word] = array(); 522 $wild = 0; 523 $xword = $word; 524 $wlen = wordlen($word); 525 526 // check for wildcards 527 if(substr($xword,0,1) == '*'){ 528 $xword = substr($xword,1); 529 $wild |= 1; 530 $wlen -= 1; 531 } 532 if(substr($xword,-1,1) == '*'){ 533 $xword = substr($xword,0,-1); 534 $wild |= 2; 535 $wlen -= 1; 536 } 537 if ($wlen < IDX_MINWORDLENGTH && $wild == 0 && !is_numeric($xword)) continue; 538 if(!isset($tokens[$xword])){ 539 $tokenlength[$wlen][] = $xword; 540 } 541 if($wild){ 542 $ptn = preg_quote($xword,'/'); 543 if(($wild&1) == 0) $ptn = '^'.$ptn; 544 if(($wild&2) == 0) $ptn = $ptn.'$'; 545 $tokens[$xword][] = array($word, '/'.$ptn.'/'); 546 if(!isset($tokenwild[$xword])) $tokenwild[$xword] = $wlen; 547 }else 548 $tokens[$xword][] = array($word, null); 549 } 550 asort($tokenwild); 551 // $tokens = array( base word => array( [ query word , grep pattern ] ... ) ... ) 552 // $tokenlength = array( base word length => base word ... ) 553 // $tokenwild = array( base word => base word length ... ) 554 555 $length_filter = empty($tokenwild) ? $tokenlength : min(array_keys($tokenlength)); 556 $indexes_known = idx_indexLengths($length_filter); 557 if(!empty($tokenwild)) sort($indexes_known); 558 // get word IDs 559 $wids = array(); 560 foreach($indexes_known as $ixlen){ 561 $word_idx = idx_getIndex('w',$ixlen); 562 // handle exact search 563 if(isset($tokenlength[$ixlen])){ 564 foreach($tokenlength[$ixlen] as $xword){ 565 $wid = array_search("$xword\n",$word_idx); 566 if(is_int($wid)){ 567 $wids[$ixlen][] = $wid; 568 foreach($tokens[$xword] as $w) 569 $result[$w[0]][] = "$ixlen*$wid"; 570 } 571 } 572 } 573 // handle wildcard search 574 foreach($tokenwild as $xword => $wlen){ 575 if($wlen >= $ixlen) break; 576 foreach($tokens[$xword] as $w){ 577 if(is_null($w[1])) continue; 578 foreach(array_keys(preg_grep($w[1],$word_idx)) as $wid){ 579 $wids[$ixlen][] = $wid; 580 $result[$w[0]][] = "$ixlen*$wid"; 581 } 582 } 583 } 584 } 585 return $wids; 586} 587 588/** 589 * Lookup words in index 590 * 591 * Takes an array of word and will return a list of matching 592 * documents for each one. 593 * 594 * Important: No ACL checking is done here! All results are 595 * returned, regardless of permissions 596 * 597 * @author Andreas Gohr <andi@splitbrain.org> 598 */ 599function idx_lookup($words){ 600 global $conf; 601 602 $result = array(); 603 604 $wids = idx_getIndexWordsSorted($words, $result); 605 if(empty($wids)) return array(); 606 607 // load known words and documents 608 $page_idx = idx_getIndex('page',''); 609 610 $docs = array(); // hold docs found 611 foreach(array_keys($wids) as $wlen){ 612 $wids[$wlen] = array_unique($wids[$wlen]); 613 $index = idx_getIndex('i',$wlen); 614 foreach($wids[$wlen] as $ixid){ 615 if($ixid < count($index)) 616 $docs["$wlen*$ixid"] = idx_parseIndexLine($page_idx,$index[$ixid]); 617 } 618 } 619 620 // merge found pages into final result array 621 $final = array(); 622 foreach($result as $word => $res){ 623 $final[$word] = array(); 624 foreach($res as $wid){ 625 $hits = &$docs[$wid]; 626 foreach ($hits as $hitkey => $hitcnt) { 627 if (!isset($final[$word][$hitkey])) { 628 $final[$word][$hitkey] = $hitcnt; 629 } else { 630 $final[$word][$hitkey] += $hitcnt; 631 } 632 } 633 } 634 } 635 return $final; 636} 637 638/** 639 * Returns a list of documents and counts from a index line 640 * 641 * It omits docs with a count of 0 and pages that no longer 642 * exist. 643 * 644 * @param array $page_idx The list of known pages 645 * @param string $line A line from the main index 646 * @author Andreas Gohr <andi@splitbrain.org> 647 */ 648function idx_parseIndexLine(&$page_idx,$line){ 649 $result = array(); 650 651 $line = trim($line); 652 if($line == '') return $result; 653 654 $parts = explode(':',$line); 655 foreach($parts as $part){ 656 if($part == '') continue; 657 list($doc,$cnt) = explode('*',$part); 658 if(!$cnt) continue; 659 $doc = trim($page_idx[$doc]); 660 if(!$doc) continue; 661 // make sure the document still exists 662 if(!page_exists($doc,'',false)) continue; 663 664 $result[$doc] = $cnt; 665 } 666 return $result; 667} 668 669/** 670 * Tokenizes a string into an array of search words 671 * 672 * Uses the same algorithm as idx_getPageWords() 673 * 674 * @param string $string the query as given by the user 675 * @param arrayref $stopwords array of stopwords 676 * @param boolean $wc are wildcards allowed? 677 */ 678function idx_tokenizer($string,&$stopwords,$wc=false){ 679 $words = array(); 680 $wc = ($wc) ? '' : $wc = '\*'; 681 682 if(preg_match('/[^0-9A-Za-z]/u', $string)){ 683 // handle asian chars as single words (may fail on older PHP version) 684 $asia = @preg_replace('/('.IDX_ASIAN.')/u',' \1 ',$string); 685 if(!is_null($asia)) $string = $asia; //recover from regexp failure 686 687 $arr = explode(' ', utf8_stripspecials($string,' ','\._\-:'.$wc)); 688 foreach ($arr as $w) { 689 if (!is_numeric($w) && strlen($w) < IDX_MINWORDLENGTH) continue; 690 $w = utf8_strtolower($w); 691 if($stopwords && is_int(array_search("$w\n",$stopwords))) continue; 692 $words[] = $w; 693 } 694 }else{ 695 $w = $string; 696 if (!is_numeric($w) && strlen($w) < IDX_MINWORDLENGTH) return $words; 697 $w = strtolower($w); 698 if(is_int(array_search("$w\n",$stopwords))) return $words; 699 $words[] = $w; 700 } 701 702 return $words; 703} 704 705//Setup VIM: ex: et ts=4 enc=utf-8 : 706