Ejemplo n.º 1
0
 /** Creating of the table with reverse dictionary by means reversed page.page_title
  */
 public static function create_reverse_table()
 {
     global $LINK_DB;
     $query = "DROP TABLE IF EXISTS `pw_reverse_dict`";
     $LINK_DB->query_e($query, "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
     $query = "CREATE TABLE `pw_reverse_dict`(" . "`page_id` int(10) unsigned NOT NULL," . "`reverse_page_title` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL," . "PRIMARY KEY (`page_id`),KEY `idx_reverse_page_title` (`reverse_page_title`(7)))";
     $LINK_DB->query_e($query, "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
     $query = "SELECT count(*) as count FROM page";
     $res_page = $LINK_DB->query_e($query, "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
     $row = $res_page->fetch_object();
     $num_pages = $row->count;
     for ($i = 0; $i < $num_pages; $i += 27000) {
         $query = "SELECT id, page_title FROM page order by id LIMIT {$i},27000";
         $res_page = $LINK_DB->query_e($query, "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
         $query = "INSERT INTO `pw_reverse_dict` VALUES ";
         $tmp = array();
         while ($row = $res_page->fetch_object()) {
             $tmp[] = "(" . $row->id . ", '" . str_replace("'", "\\'", PWString::reverseString($row->page_title)) . "')";
         }
         $LINK_DB->query_e($query . join(', ', $tmp), "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
     }
     print "<p>The table <b>pw_reverse_dict</b> is created</p>";
 }
Ejemplo n.º 2
0
        }
        if (TLang::isExist($lang)) {
            $query .= " and lang_id=" . (int) $lang;
        }
        $query .= " group by pw_reverse_dict.page_id";
    }
    $query .= " order by reverse_page_title LIMIT 0,{$limit}";
    //    $query = "SELECT id, page_title FROM page order by page_title LIMIT 0,100";
    //print $query;
    $res_page = $link_db->query_e($query, "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
    print "<div style=\"width:50%; text-align:right\">";
    $count = 0;
    while ($row = $res_page->fetch_object()) {
        // meaning.wiki_text_id>0 === words with non-empty definitions
        // relation.meaning_id=meaning.id === words with semantic relations
        /*
            	$query = "SELECT count(*) as count FROM lang_pos, meaning, relation WHERE lang_pos.page_id='".$row->page_id."' and lang_pos.id=meaning.lang_pos_id and meaning.wiki_text_id>0 ".
        		"and relation.meaning_id=meaning.id LIMIT 0,10000";
                $res_meaning = $link_db -> query_e($query,"Query failed in file <b>".__FILE__."</b>, string <b>".__LINE__."</b>");
                $row_meaning = $res_meaning -> fetch_object();
                if ($row_meaning->count >0) {
        */
        $word = PWString::reverseString($row->reverse_page_title);
        //    	    $word = $row->page_title;
        print "<a href=\"http://" . WIKT_LANG . ".wiktionary.org/wiki/{$word}\">|{$word}|</a><br >\n";
        $count++;
        //    	}
    }
    print "</div>\n" . "<p>There are founded {$count} words</p>\n";
}
include LIB_DIR . "footer.php";
Ejemplo n.º 3
0
<?php

require "../../config.php";
$str = 'азбука';
//mb_internal_encoding('utf8');
//print mb_substr($str,0,1);
print PWString::reverseString($str);