Example #1
0
echo isset($search_type) && $search_type == 'sub' ? " selected" : '';
?>
>substring search</option>
    </select>
    <input type="submit" value="view page">
</form>
<?php 
if (isset($page_title)) {
    if (isset($search_type) && $search_type == 'sub') {
        $page_title = "%{$page_title}%";
    }
    $limit_request = 100;
    Piwidict::setLimitRequest($limit_request);
    $tpage = new TPage();
    $total_num = $tpage->countPageByTitle($page_title);
    $pageObj_arr = $tpage->getByTitle($page_title);
    if ($pageObj_arr == NULL) {
        print "<p>The word has not founded.</p>\n";
    } else {
        if ($total_num > 1) {
            print "<p>There are founded {$total_num} words.</p>\n";
            if ($limit_request > 0 && $limit_request < $total_num) {
                print "Restriction on the search for a maximum of {$limit_request} records";
            }
            //ограничение на поиск не более 100 записей
        }
        if (is_array($pageObj_arr)) {
            foreach ($pageObj_arr as $pageObj) {
                print "<h2 title=\"TPage->page_title\" style=\"color: #006a4e\">" . $pageObj->getPageTitle() . "</h2>\n" . "<p>Source page at " . TPage::getURLWithLinkText($pageObj->getPageTitle()) . "</p>";
                $lang_pos_arr = $pageObj->getLangPOS();
                if (is_array($lang_pos_arr)) {
Example #2
0
 /** Gets list of semantically related words.
  * If page title is not exist, then return empty array.
  * @return array, where keys are related words, values are arrays of their relation type names
  */
 public static function getPageRelations($page_title)
 {
     $relations = array();
     // return array, if exact search then returns only one word
     list($page_obj) = TPage::getByTitle($page_title);
     $lang_pos_arr = $page_obj->getLangPOS();
     if (is_array($lang_pos_arr)) {
         foreach ($lang_pos_arr as $lang_pos_obj) {
             $meaning_arr = $lang_pos_obj->getMeaning();
             if (is_array($meaning_arr)) {
                 foreach ($meaning_arr as $meaning_obj) {
                     $relation_arr = $meaning_obj->getRelation();
                     if (is_array($relation_arr)) {
                         foreach ($relation_arr as $relation_obj) {
                             $relations[$relation_obj->getWikiText()->getText()][] = $relation_obj->getRelationType()->getName();
                         }
                     }
                 }
             }
         }
     }
     ksort($relations);
     return $relations;
 }
Example #3
0
 // SimpleXMLElement Object
 $dword = $elem->DestWord;
 // SimpleXMLElement Object
 $srel = $elem->SemanticRelation;
 // String
 $sword_title = $sword->word;
 // String
 $dword_title = $dword->word;
 // String
 $sword_mean = $sword->meaning;
 // String
 $dword_mean = $dword->meaning;
 // String
 list($sword_tpage) = TPage::getByTitle($sword_title);
 // TPage object
 $dword_tpage = TPage::getByTitle($dword_title);
 // TPage object
 //print_r($sword_tpage);
 print "{$sword_title}({$sword_id}) = {$sword_mean}\n\n";
 // checking if those meanings exist in DB
 $sword_lang_pos_arr = $sword_tpage->getLangPOS();
 if (is_array($sword_lang_pos_arr)) {
     foreach ($sword_lang_pos_arr as $langPOSObj) {
         $meaning_arr = $langPOSObj->getMeaning();
         if (is_array($meaning_arr)) {
             foreach ($meaning_arr as $meaningObj) {
                 $meaning_id = $meaningObj->getID();
                 $meaning_wiki_text = $meaningObj->getWikiText()->getWikifiedText();
                 print "<li>{$meaning_wiki_text}";
             }
         }