return; } $title = "OpenThesaurus admin interface: Search senses != NULL"; include "../include/top.php"; $i = 1; $query = sprintf("SELECT id, distinction FROM meanings\n\t\tWHERE distinction IS NOT NULL\n\t\t\tAND hidden = 0\n\t\t\tORDER BY id"); $db->query($query); while ($db->next_record()) { ?> <?php print $i; ?> . <a href="../synset.php?id=<?php print $db->f('id'); ?> "> <?php print join(', ', getSynset($db->f('id'))); ?> </a> in terms of '<?php print $db->f('distinction'); ?> ' <br /> <?php $i++; } include "../include/bottom.php"; page_close();
function setNewAntonym($thisWMID, $newWMID) { global $db; $this_id = myaddslashes($thisWMID); $new_antonym_id = myaddslashes($newWMID); $query = sprintf("SELECT id FROM antonyms\n\t\tWHERE word_meaning_id1 = %d OR word_meaning_id2 = %d", $this_id, $this_id); #print $query."<p>"; $db->query($query); if ($db->nf() == 0) { $next_id = $db->nextid("antonyms"); # The INSERT statement can lead to an duplicate key error if the new antonym # is already connected to a different word as its antonym, so check before: $query = sprintf("SELECT * FROM antonyms WHERE word_meaning_id1 = %d OR word_meaning_id2 = %d", myaddslashes($newWMID), myaddslashes($newWMID)); $db->query($query); if ($db->nf() > 0) { print T_("Error: the antonym you selected is already connected to a different word."); exit; } $query = sprintf("INSERT INTO antonyms (id, word_meaning_id1, word_meaning_id2)\n\t\t\tVALUES (%d, %d, %d)", $next_id, myaddslashes($newWMID), myaddslashes($thisWMID)); #print $query; $db->query($query); // Logging: // FIXME: should be moved before the INSERT query is executed, but the // INSERT can lead to an error and we don't want to log the action in that case: list($word1, $mid) = getAntonymWord($this_id, $db); list($word2, $mid) = getAntonymWord($newWMID, $db); doLog(join(', ', getSynset($this_id, 3)), $mid, ADD_ANTONYM, $word1 . "<->" . $word2); } else { if ($db->nf() == 1) { // Logging: list($word1, $mid) = getAntonymWord($this_id, $db); list($word2, $mid) = getAntonymWord($newWMID, $db); doLog(join(', ', getSynset($this_id, 3)), $mid, CHANGE_ANTONYM, $word1 . "<->" . $word2); # one of the next two UPDATE statements will succeed: $query = sprintf("UPDATE antonyms\n\t\t\tSET word_meaning_id2 = %d\n\t\t\tWHERE word_meaning_id1 = %d", $newWMID, $this_id); #print $query."<p>"; $db->query($query); $query = sprintf("UPDATE antonyms\n\t\t\tSET word_meaning_id1 = %d\n\t\t\tWHERE word_meaning_id2 = %d", $newWMID, $this_id); #print $query."<p>"; $db->query($query); } else { print "Internal error: more than one match for {$query}"; return; } } }
} $c = 0; while (list($id, $val) = each($ids)) { $query = sprintf("SELECT id\n\t\tFROM word_meanings\n\t\tWHERE word_meanings.meaning_id = %d", $id); #print $query."<br>"; $db->query($query); $s = getSynset($id); if (sizeof($s) == $synset_size) { $c++; ?> <?php print $c; ?> . <a href="../synset.php?id=<?php print $id; ?> "><?php print join(', ', getSynset($id)); ?> </a> <a href="hide.php?id=<?php print $id; ?> ">(hide)</a> <br /> <?php } } include "../include/bottom.php"; page_close();
include "../include/phplib/prepend.php3"; page_open(array("sess" => "Thesaurus_Session", "auth" => "Thesaurus_Auth")); $db = new DB_Thesaurus(); include "../include/tool.php"; if ($auth->auth['uname'] != 'admin') { print "Access denied."; return; } $title = "OpenThesaurus admin interface: random synsets"; include "../include/top.php"; $word = ""; // Show random word # FIXME: this can fail if the word is in no synset: $query = sprintf("SELECT id FROM meanings ORDER BY RAND() LIMIT 40"); #print $query; $db->query($query); ?> <?php $word_ids = array(); $words = array(); $prev_word_id = -1; while ($db->next_record()) { #print $db->f('id')."<br>"; print join(', ', getSynset($db->f('id'))) . "<br>\n"; } ?> <?php include "../include/bottom.php"; page_close();
$i++; } $word_regexp = join('|', $word_regexp_array); $word_query .= ")"; $query = sprintf("SELECT words.id AS word_id, word, meaning_id\n\t\tFROM words, word_meanings, meanings\n\t\tWHERE \n\t\t\t{$word_query} AND\n\t\t\twords.id = word_meanings.word_id AND\n\t\t\tword_meanings.meaning_id = meanings.id AND\n\t\t\tmeanings.hidden = 0 AND\n\t\t\tmeanings.id != %d\n\t\tORDER BY meaning_id", $_GET['meaning_id']); $db->query($query); $prev_word_id = -1; $prev_meaning_id = -1; while ($db->next_record()) { if ($db->f('meaning_id') == $prev_meaning_id) { # filter duplicates: $prev_meaning_id = $db->f('meaning_id'); continue; } $prev_meaning_id = $db->f('meaning_id'); $synset = getSynset($db->f('meaning_id')); $synset_str = join(', ', $synset); # TODO: \b doesn't react on "�" etc.: $synset_str = preg_replace("/\\b({$word_regexp})\\b/i", "<strong>\$1</strong>", $synset_str); ?> <span class="myhoverbright"><label><input type="radio" name="super_id" value="<?php print $db->f('meaning_id'); ?> " /><?php print T_("Use synset:"); ?> </label> <a href="synset.php?id=<?php print $db->f('meaning_id'); ?> "><?php
<?php include "../include/phplib/prepend.php3"; page_open(array("sess" => "Thesaurus_Session", "auth" => "Thesaurus_Auth")); $db = new DB_Thesaurus(); include "../include/tool.php"; if ($auth->auth['uname'] != 'admin') { print "Access denied."; return; } $title = "OpenThesaurus admin interface: find short forms"; include "../include/top.php"; $i = 1; print "<p><b>Words that end with a dot (but not \"...\"):</b></p>"; $query = "SELECT word, words.id AS wid, word_meanings.meaning_id AS mid\n\tFROM words, word_meanings, meanings\n\tWHERE \n\t\twords.word LIKE '%.' AND\n\t\t(words.word NOT LIKE '%...') AND\n\t\tword_meanings.word_id = words.id AND\n\t\tmeanings.id = word_meanings.meaning_id AND\n\t\tmeanings.hidden = 0\n\tORDER BY word"; $db->query($query); while ($db->next_record()) { #print $db->f('mid'); $s = getSynset($db->f('mid')); #print $i.". <a title=\"hide\" href=\"hide.php?id=".$db->f('mid')."\">".join(', ', $s)."</a>"; print $i . ". <a href=\"../synset.php?id=" . $db->f('mid') . "\">" . join(', ', $s) . "</a>"; print "<br>"; #print $i.". <a href=\"../synset.php?id=".$db->f('mid')."\">".join(', ', $s)."</a><br>"; #print $i.". <a href=\"../synset.php?word=".urlencode($db->f('word'))."\">".$db->f('word')."</a><br>\n"; $i++; } include "../include/bottom.php"; page_close();
include "../include/phplib/prepend.php3"; page_open(array("sess" => "Thesaurus_Session", "auth" => "Thesaurus_Auth")); $db = new DB_Thesaurus(); include "../include/tool.php"; if ($auth->auth['uname'] != 'admin') { print "Access denied."; return; } $title = "OpenThesaurus admin interface: average synset size"; include "../include/top.php"; $i = 1; $query = "SELECT id FROM meanings\n\tWHERE hidden = 0"; $db->query($query); $i = 0; $count = 0; while ($db->next_record()) { if ($i % 1000 == 0) { print "{$i}...<br>\n"; flush(); } $synset = getSynset($db->f('id')); $count = $count + sizeof($synset); $i++; } print "<p>"; print "Synsets: " . $db->nf() . "<br>"; print "Words in synsets: " . $count . "<br>"; print "Words/synset: " . $count / $db->nf() . "<br>"; include "../include/bottom.php"; page_close();
/** Get the synset as a string. */ function getSynsetString($id, $max_elements = -1) { $syn_arr = getSynset($id, $max_elements); $s = join(', ', $syn_arr); return $s; }
// first read all non-hidden meanings into an // meaning -> word1,word2,... hash table: while ($db->next_record()) { if ($db->f('meaning_id') != $prev_id) { array_push($ids, $db->f('word_id')); $meanings[$prev_id] = $ids; $ids = array(); } else { array_push($ids, $db->f('word_id')); } $prev_id = $db->f('meaning_id'); } $keys = array_keys($meanings); sort($keys); foreach ($keys as $key) { $meaning_id = $key; $word_ids = $meanings[$key]; print $meaning_id . "<br>\n"; flush(); foreach ($keys as $key) { #print "*".join('-', $word_ids)." -- \n"; $meaning_id_tmp = $key; $word_ids_tmp = $meanings[$key]; if ($meaning_id != $meaning_id_tmp && sizeof(array_intersect($word_ids, $word_ids_tmp)) > 2) { #print $meaning_id.": ".join(',', $word_ids)."<br>"; print join(',', getSynset($meaning_id)) . " -- " . join(',', getSynset($meaning_id_tmp)) . "<br>\n"; } } } include "../../include/bottom.php"; page_close();
$page = "get_delete_comment"; $title = _("Comment on the deletion"); include "../include/top.php"; ?> <form action="do_save.php" method="post" name="commentform"> <input type="hidden" name="do_remove" value="1" /> <input type="hidden" name="meaning_id" value="<?php print intval(uservar('meaning_id')); ?> " /> <table cellpadding="0" cellspacing="2" border="0"> <tr> <td colspan="2"><?php print sprintf(_("Please add a short comment that explains why the synset <span class='inp'>%s</span> can be deleted:"), join(', ', getSynset(uservar('meaning_id')))); ?> </td> </tr> <tr><td> </td></tr> <tr> <td><?php print _("Short comment:"); ?> </td> <td><input size="50" type="text" name="comment" value="" /></td> </tr> <tr> <td></td> <td align="right"><?php print "<input type=\"submit\" value=\"" . _("Send") . "\" />";
} foreach ($del_list as $id) { # delete from synset $query = sprintf("SELECT word FROM words WHERE id = %d", $id); $db->query($query); $db->next_record(); doLog(unescape($db->f('word')), uservar('meaning_id'), REMOVE_SYNONYM); $query = sprintf("DELETE FROM word_meanings\n\t\tWHERE\n\t\t\tword_id = %d AND\n\t\t\tmeaning_id = %d", $id, uservar('meaning_id')); $db->query($query); } if (uservar('do_remove') == 1) { $title = T_("Synset removed"); include "include/top.php"; ?> <p><?php print sprintf(T_("The synset <span class='inp'>%s</span> has been deleted."), join(', ', getSynset(uservar('meaning_id')))); ?> </p> <p><a href="./"><?php print T_("Return to homepage"); ?> </a></p> <?php include "include/bottom.php"; page_close(); return; } else { // time() tries to force reload: $url = sprintf("synset.php?id=%d&changed=1&oldmode=%s&rand=%d", intval(uservar('meaning_id')), uservar('mode'), time());
} else { print T_("No superordinate concept defined yet for this synset. Set one now:"); ?> <input accesskey="o" type="text" name="super_new" value="" /> <?php } ?> <br /> <?php $query = sprintf("SELECT id FROM meanings WHERE super_id = %s", $meaning_id); $db->query($query); $subsets = array(); while( $db->next_record() ) { array_push($subsets, '<a href="synset.php?id='.$db->f('id').'">'.join(', ', getSynset($db->f('id'), $max_synset_size)).'</a>'); } if( sizeof($subsets) > 0 ) { print T_("Subordinate concepts:")." "; print join(' -- ', $subsets); $can_delete = 0; $sub_defined = 1; } else { print T_("There are no subordinate concepts yet for this synset."); } ?> </td> </tr> <?php if( $sub_defined || $super_defined ) { ?> <tr> <td></td>
<?php include "../../include/phplib/prepend.php3"; page_open(array("sess" => "Thesaurus_Session", "auth" => "Thesaurus_Auth")); $db = new DB_Thesaurus(); $db_tmp = new DB_Thesaurus(); include "../../include/tool.php"; if ($auth->auth['uname'] != 'admin') { print "Access denied."; return; } $title = "OpenThesaurus admin interface: Loose synsets"; include "../../include/top.php"; print "<p>Searching synsets which have a superordinate synset but\nwhich are not below the top synset...</p>"; $query = sprintf("SELECT id FROM meanings WHERE hidden = 0"); $db->query($query); $i = 1; print "Checking " . $db->nf() . " meanings:<br />\n"; while ($db->next_record()) { $synsets = getSuperordinateSynsets($db_tmp, $db->f('id')); if (sizeof($synsets) > 0) { $top_id = $synsets[sizeof($synsets) - 1]; if (sizeof($synsets) > 0 && $top_id != TOP_SYNSET_ID) { print "{$i}. <a href=\"../synset.php?id=" . $db->f('id') . "\">" . join(', ', getSynset($db->f('id'), 3)) . "</a> is a " . "<a href=\"../synset.php?id=" . $top_id . "\">" . join(', ', getSynset($top_id, 3)) . "</a><br />\n"; $i++; } } } print "<hr />\n"; page_close();