<?php

$count_exec_time = 1;
include "../../../config.php";
include LIB_DIR . "header.php";
$php_self = "meaning_to_lemmas.php";
if (isset($word)) {
    $word_h1 = " &quot;" . TPage::getURL($word) . "&quot;";
} else {
    $word_h1 = '';
}
?>
<h1>Example for lemmatising of words from meanings of given word<?php 
echo $word_h1;
?>
</h1>

<form action="<?php 
echo $php_self;
?>
" method="GET">
    <input type="text" size="30" name="word" value="<?php 
if (isset($word)) {
    print $word;
}
?>
">
    <input type="submit" value="search">
</form>
<?php 
if (isset($word)) {
Beispiel #2
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
                        $relation_wiki_text = $relation_obj->getWikiText();
                        if ($relation_wiki_text != NULL) {
                            print "<tr><td>" . ++$counter . ".</td><td>" . TPage::getURL($row->page_title) . "</td><td>" . $relation_type->getName() . "</td><td>" . $relation_wiki_text->getText() . "</td></tr>\n";
                        }
                    }
                }
                // eo relation
            }
        }
        // eo meaning
    }
    print "</table><br />\nTotal semantic relations (with these parameters): {$counter}<BR>";
}
include LIB_DIR . "footer.php";
Beispiel #3
0
if (isset($page_title)) {
    if ($page_title == "") {
        print "<p>Введите слово!</p>";
    } else {
        $pageObj_arr = Tpage::getByTitle($page_title);
        if ($pageObj_arr == NULL) {
            print "<p>The word has not founded.</p>\n";
        } else {
            if (sizeof($pageObj_arr) > 1) {
                print "<p>There are founded " . sizeof($pageObj_arr) . " words.</p>\n";
            }
            if (is_array($pageObj_arr)) {
                foreach ($pageObj_arr as $pageObj) {
                    // вывод слова и ссылка на статью в Викисловаре
                    print "<p>Source page at " . TPage::getURL($pageObj->getPageTitle(), WIKT_LANG . ".wiktionary.org") . "</p>";
                    $lang_pos_arr = $pageObj->getLangPOS();
                    if (is_array($lang_pos_arr)) {
                        foreach ($lang_pos_arr as $langPOSObj) {
                            // вывод языковой принадлежности и части речи
                            print "<h3 title=\"TPage::TLangPOS::TLang->name\">" . $langPOSObj->getLang()->getName() . "</h3>\n" . "<p title=\"TPage::TLangPOS::TPOS->name\">Part of speach: <b>" . $langPOSObj->getPOS()->getName() . "</b></p>\n";
                            $meaning_arr = $langPOSObj->getMeaning();
                            $count_meaning = 1;
                            if (is_array($meaning_arr)) {
                                foreach ($meaning_arr as $meaningObj) {
                                    $meaning_id = $meaningObj->getID();
                                    // LABELS OF MEANING
                                    $labelMeaning_arr = $meaningObj->getLabelMeaning();
                                    $label_name_arr = array();
                                    if (is_array($labelMeaning_arr)) {
                                        foreach ($labelMeaning_arr as $labelMeaningObj) {
Beispiel #4
0
    <p><input type="submit" name="view_list" value="search"></p>
</form>
<?php 
if (isset($view_list) && $view_list) {
    $query_lang_pos = "SELECT lang_pos.id as id, page_title, relation_type_id, wiki_text.text as wiki_text FROM lang_pos, page, relation, meaning, wiki_text " . "WHERE lang_pos.page_id=page.id AND relation.meaning_id=meaning.id AND meaning.lang_pos_id=lang_pos.id AND relation.wiki_text_id=wiki_text.id AND wiki_text.text is not null";
    if ($relation_type_id) {
        $query_lang_pos .= " and relation_type_id=" . (int) $relation_type_id;
    }
    if ($lang_id) {
        $query_lang_pos .= " and lang_id=" . (int) $lang_id;
    }
    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";
    //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>");
    $numAll = $link_db->query_count($result_lang_pos);
    print "{$numAll} semantic relations (with these parameters) are found";
    $result_lang_pos = $link_db->query_e($query_lang_pos . " LIMIT {$start_rec},{$limit}", "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
    print "<table border=1>\n";
    $counter = $start_rec;
    while ($row = $result_lang_pos->fetch_object()) {
        print "<tr><td>" . ++$counter . ".</td><td>" . TPage::getURL($row->page_title) . "</td><td>" . TRelationType::getNameByID($row->relation_type_id) . "</td><td>" . $row->wiki_text . "</td></tr>\n";
    }
    print "</table><br />\n" . WForm::goNextStep($numAll, $limit, $php_self . "?lang_id={$lang_id}&pos_id={$pos_id}&relation_type_id={$relation_type_id}&page_title={$page_title}&view_list=1", 2, "Go to", $step_s);
}
include LIB_DIR . "footer.php";
Beispiel #5
0
echo $substring;
?>
"></p>
    <p><input type="submit" name="view_list" value="view"></p>
</form>
<?php 
if (isset($view_list) && $view_list) {
    $query = "SELECT meaning.id as meaning_id, page_title, text FROM page, lang_pos, meaning, wiki_text WHERE lang_pos.page_id=page.id and meaning.lang_pos_id=lang_pos.id and meaning.wiki_text_id=wiki_text.id " . " and text like '%{$substring}%' order by text";
    //  LIMIT $limit
    $result = $link_db->query_e($query, "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
    print "<p>" . $link_db->query_count($result) . " definitions are found</p><table border=1>\n";
    $counter = 0;
    while ($row = $result->fetch_object()) {
        // LABELS OF MEANING
        $label_name_arr = array();
        /*
        	$labelMeaning_arr = TMeaning::getByID($row->meaning_id)->getLabelMeaning();
        			
        	if (is_array($labelMeaning_arr)) foreach ($labelMeaning_arr as $labelMeaningObj)
        	    $label_name_arr[] = "<span title=\"".$labelMeaningObj->getLabel()->getName()."\">".$labelMeaningObj->getLabel()->getShortName()."</span>";
        */
        $query = "SELECT id, short_name, name FROM label, label_meaning WHERE label_meaning.label_id=label.id and label_meaning.meaning_id=" . (int) $row->meaning_id;
        $res_label = $link_db->query_e($query, "Query failed in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
        while ($row_label = $res_label->fetch_object()) {
            $label_name_arr[] = "<span title=\"" . $row_label->name . "\">" . $row_label->short_name . "</span>";
        }
        print "<tr><td>" . ++$counter . ".</td><td>" . TPage::getURL($row->page_title) . "</td><td>" . join(', ', $label_name_arr) . "</td><td>" . TWikiText::selectText($row->text, $substring, "<span style='font-weight:bold; color:#FF00FF'>", "</span>") . "</td></tr>\n";
    }
    print "</table><BR>";
}
include LIB_DIR . "footer.php";
    //        list($word1,$word2) = preg_split("/\s+/",$word_arr[0]);
    //print "<P>$word1,$word2";
    //break;
    $start = PWLemma::getIDByLemma($word1);
    $finish = PWLemma::getIDByLemma($word2);
    $word1_url = TPage::getURL($word1);
    $word2_url = TPage::getURL($word2);
    if ($start && $finish) {
        list($dist_len, $path) = PWSemanticDistance::DijkstraAlgorithmByArray($start, $finish);
        if ($path == NULL) {
            print "<p>The words '{$word1_url}' and '{$word2_url}' are not related</p>";
        } else {
            print "<p>" . (int) (sizeof($path) - 1) . " step(s), the length of distance is {$dist_len}</p>";
            print TPage::getURL(PWLemma::getLemmaByID($path[0]));
            for ($i = 1; $i < sizeof($path); $i++) {
                print " -> " . TPage::getURL(PWLemma::getLemmaByID($path[$i]));
            }
        }
    } else {
        $dist_len = 0;
        if (!$start && !$finish) {
            print "<p>The words '{$word1_url}' and '{$word2_url}' have been not found</p>";
        } elseif (!$start) {
            print "<p>The word '{$word1_url}' has been not found</p>";
        } elseif (!$finish) {
            print "<p>The word '{$word2_url}' has been not found</p>";
        }
    }
    print "<hr>";
    fwrite($fh, $word1 . "\t" . $word2 . "\t" . $dist_len . "\n");
}