$lines = preg_split("/\n/", $contents); $stopwords = array(); foreach ($lines as $line) { $line = strtolower(trim($line)); $stopwords[$line] = 1; # 1= fake value #print $line; } print "<h2>Unknown words</h2>"; $words = array(); $words = preg_split("/[\\s,:!;\\.\"\\?\\/\\-\\(\\)\\\\]+/", $_POST['text']); $words = array_unique($words); $i = 0; while (list($count, $word) = each($words)) { #$org_word = $word; $base_words = getBaseform($db, $word); if (sizeof($base_words) > 0) { $word = $base_words[0]; } # We should use a case-insensitive query here, to also find # words which are spelled with a capital first letter only because # they aoocur at the beginning of a sentence. # But UPPER(...) = UPPER(...) is too slow, so use this: $query = sprintf("SELECT word, words.id\n\t\t\tFROM words, word_meanings, meanings\n\t\t\tWHERE (word = '%s' OR word = LOWER('%s')) AND\n\t\t\t\tword_meanings.word_id = words.id AND\n\t\t\t\tword_meanings.meaning_id = meanings.id AND\n\t\t\t\tmeanings.hidden = 0", myaddslashes($word), myaddslashes($word)); $db->query($query); //$db->next_record(); $word_org = $word; $word = strtolower($word); if ($db->nf() == 0 && !array_key_exists($word, $stopwords) && !ereg("^[0-9]+\$", $word)) { $i++; ?>
<?php $queryterm = trim($_GET['word']); $links = array(); if ($queryterm != "") { $gram_related = getBaseform($db, trim($_GET['word'])); if (sizeof($gram_related) > 0) { foreach ($gram_related as $word) { if (wordInDB($db, $word) && $queryterm != $word) { array_push($links, '<a href="' . DEFAULT_SEARCH . '?word=' . urlencode($word) . '">' . $word . '</a>'); } } } } if (sizeof($links) > 0) { ?> <p class="compact"><strong><?php print _("Grammatically related words (base forms):"); ?> </strong></p> <ul class="compact"> <?php foreach ($links as $link) { ?> <li><?php print $link; ?> </li> <?php } ?>