Пример #1
0
 /** Gets TPage object by property $property_name with value $property_value.
  * @return TPage or NULL in case of error
  */
 public static function getPage($property_name, $property_value)
 {
     global $LINK_DB;
     $query = "SELECT * FROM page WHERE `{$property_name}` like '{$property_value}' order by page_title";
     $result = $LINK_DB->query_e($query, "Query failed in " . __METHOD__ . " in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
     if ($LINK_DB->query_count($result) == 0) {
         return NULL;
     }
     $page_arr = array();
     while ($row = $result->fetch_object()) {
         $page = new TPage($row->id, $row->page_title, $row->word_count, $row->wiki_link_count, $row->is_in_wiktionary, $row->is_redirect, $row->redirect_target);
         $page->lang_pos = TLangPOS::getByPage($row->id, $page);
         $page_arr[] = $page;
     }
     //  if (sizeof($page_arr
     return $page_arr;
 }
Пример #2
0
 }
 if ($pos_id) {
     $query_lang_pos .= " and pos_id=" . (int) $pos_id;
 }
 if ($page_title) {
     $query_lang_pos .= " and page_title like '%{$page_title}%'";
 }
 $query_lang_pos .= " order by page_title, id";
 // LIMIT $limit
 //print $query_lang_pos;
 $result_lang_pos = $link_db->query_e($query_lang_pos, "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
 //print $link_db -> query_count($result_lang_pos);
 print "<table border=1>\n";
 $counter = 0;
 while ($counter < $limit && ($row = $result_lang_pos->fetch_object())) {
     $lang_pos = TLangPOS::getByID($row->id);
     // 2. get array of meanings
     $meaning_arr = $lang_pos->getMeaning();
     if (is_array($meaning_arr)) {
         foreach ($meaning_arr as $meaning_obj) {
             // 3. get array of relations
             $relation_arr = $meaning_obj->getRelation();
             if (is_array($relation_arr)) {
                 foreach ($relation_arr as $relation_obj) {
                     $relation_type = $relation_obj->getRelationType();
                     //print "<p>".$relation_type->getID();
                     // 4. filter by relation type
                     if ($relation_type_id && $relation_type->getID() != $relation_type_id) {
                         continue;
                     }
                     // 5. get relation word by $wiki_text_id
Пример #3
0
print "lang_id_ru = {$lang_id_ru}<BR>";
$pos_id_noun = TPOS::getIDByName($pos_all, "noun");
$pos_id_noun_class = TPOS::getIDByName($pos_all, "noun class");
print "ID of part of speech \"noun\" = {$pos_id_noun}<BR>";
print "ID of part of speech \"noun class\" = {$pos_id_noun_class}<BR>";
$relation_type_id_hyponyms = TRelationType::getIDByName($relation_type_all, "hyponyms");
$relation_type_id_hypernyms = TRelationType::getIDByName($relation_type_all, "hypernyms");
print "ID of relation type \"hyponyms\" = {$relation_type_id_hyponyms}<BR>";
print "ID of relation type \"hypernyms\" = {$relation_type_id_hypernyms}<BR>";
print "<BR>";
$query_lang_pos = "SELECT id FROM lang_pos";
$result_lang_pos = mysqli_query($LINK_DB, $query_lang_pos) or die("Query failed (line 39) in list_hypo.php: " . mysqli_error() . ". Query: " . $query);
$counter = 0;
while ($row = mysqli_fetch_array($result_lang_pos)) {
    $lang_pos_id = $row['id'];
    $lang_pos = TLangPOS::getByID($lang_pos_id, $lang_all, $pos_all);
    // 1. filter by part of speech
    $pos_id = $lang_pos->pos->id;
    // [39] => Array ( [id] => 39 [name] => noun )
    if ($pos_id != $pos_id_noun && $pos_id != $pos_id_noun_class) {
        continue;
    }
    // print "lang_pos_id = $lang_pos_id<BR>";
    // print "pos_id = $pos_id<BR>";
    // print " ".$lang_pos->page->page_title."; ".$lang_pos->pos->name."<BR>";
    // 2. get meaning.id by lang_pos_id
    $query_meaning = "SELECT id FROM meaning WHERE lang_pos_id=" . $lang_pos_id;
    $result_meaning = mysqli_query($LINK_DB, $query_meaning) or die("Query failed (line 58) in list_hypo.php: " . mysqli_error() . ". Query: " . $query_meaning);
    while ($row_m = mysqli_fetch_array($result_meaning)) {
        $meaning_id = $row_m['id'];
        // 3. get relation by meaning_id
Пример #4
0
 /** Gets TMeaning object by page_id
  * @return TMeaning or NULL in case of error
  */
 public static function getByPageAndLang($page_id, $lang_code = '')
 {
     $meaning_arr = array();
     $lang_pos_arr = TLangPOS::getIDByPageAndLang($page_id, $lang_code);
     foreach ($lang_pos_arr as $lang_pos_id) {
         $meaning_arr = array_merge($meaning_arr, (array) self::getMeaning("lang_pos_id", $lang_pos_id));
     }
     return $meaning_arr;
 }
Пример #5
0
 /** Gets TLangPOS object by lang_id.
  * @return TLangPOS or NULL if data is absent. */
 public static function getByLang($lang_id, $lang_obj = NULL)
 {
     return TLangPOS::getLangPOS("lang_id", $lang_id, $lang_obj);
 }