19 include_once(
'TranslationWord.php');
57 $this->fakeLength = 0;
58 unset($this->allWords);
109 if(count($this->allWords) > $this->currIndex)
130 $rs =
$DB->Execute(
"SELECT Word, ID FROM ".
$Tables[
"WordIndex"]);
134 die(
"DB Error:". $this->DB->ErrorMsg());
137 while($oldWord = $rs->FetchRow())
167 $w->SetCount($count);
168 $this->allWords[] = $w;
173 $w->SetCount($w->GetCount() + $count);
199 $w->SetCount($count);
200 $this->allWords[] = $w;
205 $w->SetCount($w->GetCount() + $count);
224 die(
"WORDS: SetIDByName to a not existing word: $word, $id.\n");
241 $this->fakeLength = $length;
257 unset($this->allWords);
261 $text = str_replace(
"\n",
" ", $text);
262 $text = str_replace(
"\r",
" ", $text);
265 $text = str_replace(
"<strong>",
"", $text);
266 $text = str_replace(
"</strong>",
"", $text);
267 $text = str_replace(
"<b>",
"", $text);
268 $text = str_replace(
"</b>",
"", $text);
269 $text = str_replace(
"<i>",
"", $text);
270 $text = str_replace(
"</i>",
"", $text);
271 $text = str_replace(
"<em>",
"", $text);
272 $text = str_replace(
"</em>",
"", $text);
273 $text = str_replace(
" ",
" ", $text);
276 $wordList = preg_split(
'/[- \.,()!\?\/\\<>_:;=|\\*]/', $text, -1, PREG_SPLIT_NO_EMPTY);
279 foreach($wordList as $word)
282 $word = trim($word,
" \t\n\r:[]#'\"$+-_<>/");
285 if($word !=
"" && !is_numeric($word))
287 $this->
AddWord(strtolower($word));
310 if(empty($this->allWords))
316 foreach($this->allWords as $w)
318 if($w->GetWord() == $word)
338 if(empty($this->allWords))
344 foreach($this->allWords as $w)
346 if($w->GetID() == $id)
370 if($this->fakeLength <> 0)
376 if(empty($this->allWords))
383 foreach($this->allWords as $w)
385 $count += $w->GetCount();
407 $max = $this->
SumCount() + $otherWords->SumCount();
412 foreach($this->allWords as $w)
415 $w2 = $otherWords->FindByID($w->GetID());
421 if($w2->GetCount() == $w->GetCount())
423 $points += $w->GetCount() * 2;
427 $points += abs($w2->GetCount() - $w->GetCount()) * 2;
434 return floor((100/$max) * $points);
453 foreach($this->allWords as &$w)
464 $ok = $this->DB->Execute(
"INSERT INTO ".$this->Tables[
"WordIndex"].
" (Word) VALUES ('".
fixstr($w->GetWord()).
"')");
468 die(
"DB Error:". $this->DB->ErrorMsg().
" Line: ".__LINE__);
470 if(!$this->DB->Insert_ID())
472 die(
"DB Error: Insert_ID not supported. Line: ".__LINE__);
476 $w->SetID($this->DB->Insert_ID());