Example #1
0
function process_tags($title)
{
    global $conn;
    $title_array = explode(" ", strtolower($title));
    $tag_count = 0;
    pr($title_array);
    foreach ($title_array as $tag) {
        $tag = trim($tag);
        $tag = strtolower($tag);
        $tag_count++;
        if ($tag_count == 15) {
            break;
        }
        $tag = str_replace("#", "", $tag);
        $tag = str_replace(":", "", $tag);
        $tag = str_replace(",", "", $tag);
        $tag = str_replace(".", "", $tag);
        $tag = str_replace(";", "", $tag);
        $tag = str_replace(">", "", $tag);
        $tag = str_replace("<", "", $tag);
        $tag = str_replace('"', "", $tag);
        $tag = str_replace("'", "", $tag);
        $tag = str_replace("،", "", $tag);
        $tag = str_replace("~", "", $tag);
        $tag = str_replace("`", "", $tag);
        $tag = str_replace("(", "", $tag);
        $tag = str_replace(")", "", $tag);
        $tag = str_replace("»", "", $tag);
        $tag = str_replace("«", "", $tag);
        $tag = preg_replace("/[a-zA-Z0-9]+/", '', $tag);
        $tag_encoding = mb_detect_encoding($tag);
        // echo($tag_encoding . '<br />');
        if ($tag_encoding != "" && $tag_encoding == 'UTF-8' && !is_numeric($tag) && mb_strlen($tag, "UTF-8") > 2) {
            //just arabic and not number and tag length > 2 and it's noun
            echo check_if_tag_exists($tag);
        }
    }
}
function process_tags($title, $aid)
{
    global $conn;
    $title_array = explode(" ", strtolower($title));
    $words = FILE("useless_words.txt");
    $real_tags = array_diff($title_array, $words);
    //$obj = new I18N_Arabic_WordTag();
    //    echo($title . '<br />');
    //   echo($aid . '<br />');
    //pr($real_tags);
    //      exit;
    $tag_count = 0;
    foreach ($real_tags as $tag) {
        $tag = trim($tag);
        $tag = strtolower($tag);
        $tag_count++;
        if ($tag_count == 15) {
            break;
        }
        //$taggedText = $obj->tagText($tag);
        //echo('<br />verb:<br />'); pr($taggedText);
        /* $word = '';
           $tag_type = '';
              
           if (is_array($taggedText[0])) {
               list($word, $tag_type) = $taggedText[0];
           }   */
        //     echo('$word: ' . $word . '<br />');
        //   echo('$tag_type: ' . $tag_type . '<br /><br />');
        $tag = str_replace("#", "", $tag);
        $tag = str_replace(":", "", $tag);
        $tag = str_replace(",", "", $tag);
        $tag = str_replace(".", "", $tag);
        $tag = str_replace(";", "", $tag);
        $tag = str_replace(">", "", $tag);
        $tag = str_replace("<", "", $tag);
        $tag = str_replace('"', "", $tag);
        $tag = str_replace("'", "", $tag);
        $tag = str_replace("،", "", $tag);
        $tag = str_replace("~", "", $tag);
        $tag = str_replace("`", "", $tag);
        $tag = str_replace("(", "", $tag);
        $tag = str_replace(")", "", $tag);
        $tag = str_replace("»", "", $tag);
        $tag = str_replace("«", "", $tag);
        $tag = preg_replace("/[a-zA-Z0-9]+/", '', $tag);
        $tag_encoding = mb_detect_encoding($tag);
        //if ($tag_encoding != "" && $tag_encoding == 'UTF-8' && !is_numeric($tag) && (mb_strlen($tag, "UTF-8") > 2) /*&& ($tag_type == 1)*/) {   //just arabic and not number and tag length > 2 and it's noun
        if ($tag_encoding != "" && $tag_encoding == 'UTF-8' && !is_numeric($tag) && mb_strlen($tag, "UTF-8") > 2) {
            //just arabic and not number and tag length > 2 and it's noun
            $tag_id = check_if_tag_exists($tag);
            // pr($tag_id);  exit;
            if ($tag_id) {
                if ($tag_id != 0) {
                    $aid_tid = check_if_article_assoc_for_such_tag($aid, $tag_id);
                    if (!$aid_tid) {
                        $tag_query = "insert into article_tags (aid, tid) value ('{$aid}', '" . $tag_id . "')";
                        echo '<br />$tag_query1: ' . $tag_query . '<br />';
                        $res = $conn->db_query($tag_query);
                    }
                }
            } else {
                if ($tag != "") {
                    //   $new_tag_id = insert_new_tag($tag, 1);
                    // update_parent($new_tag_id);
                }
                /*if ($new_tag_id != 0) {
                      $tag_query = "insert into article_tags (aid, tid) value ('$aid', '$new_tag_id')";
                      echo('<br />$tag_query2: ' . $tag_query . '<br />');
                      $res = $conn->db_query($tag_query);
                  } */
            }
        }
    }
}
Example #3
0
 $tag_name = str_replace("<", "", $tag_name);
 $tag_name = str_replace("\"", "", $tag_name);
 $tag_name = str_replace("'", "", $tag_name);
 // $tag_name = str_replace("،", "", $tag_name);
 $tag_name = str_replace("~", "", $tag_name);
 $tag_name = str_replace("`", "", $tag_name);
 $tag_name = str_replace("'", "", $tag_name);
 $tag_name = str_replace('"', "", $tag_name);
 $tag_name = str_replace("(", "", $tag_name);
 $tag_name = str_replace(")", "", $tag_name);
 $tag_name = str_replace("»", "", $tag_name);
 $tag_name = str_replace("«", "", $tag_name);
 $tag_name = trim($tag_name);
 if ($tag_name != "") {
     //  echo('$tag_name: ' . $tag_name . '<br />');
     $found = check_if_tag_exists($tag_name);
     if (!$found) {
         if ($count == 0) {
             //parent
             if ($tag_name != "") {
                 $new_tid = insert_new_tag($tag_name, $tag_name);
                 $_COOKIE['parent_id'] = $new_tid;
                 $_COOKIE['parent_name'] = $tag_name;
                 update_parent($new_tid);
             }
         } else {
             if ($tag_name != "") {
                 insert_new_tag($_COOKIE['parent_name'], $tag_name, $_COOKIE['parent_id']);
             }
         }
         $count++;