[META] Mod StopWords in Dynamic Meta tags

Support for the phpBB3 SEO mods released in the phpBB3 SEO Toolikt forum.

Moderator: Moderators

[META] Mod StopWords in Dynamic Meta tags

Postby kar » Wed Nov 05, 2008 8:31 pm

Hello all.

I wrote small mod for exclude some words from Dynamic Meta tags in PHPBB3 Premod.
I change in includes/functions.php
Code: Select all
   function make_keywords($text) {
      $keywords = '';
      $num = 0;
      $text = preg_replace(array('`&(amp;)?#?[a-z0-9]+;`i', '`[[:punct:]]+`', '`[\s]+`'), ' ', strip_tags($text) );
      $text = explode(' ', $text);
      // We take the most used words first
      $text = array_count_values($text);
      arsort($text);
      foreach ($text as $word => $count) {
         if ( utf8_strlen($word) > $this->mconfig['wordminlen'] ) {
            $keywords .= empty($keywords) ? $word : ', ' . $word;
            $num++;
            if ( $num >= $this->mconfig['keywordlimit'] ) {   
               break;
            }
         }   
      }
      return $keywords;
   }

to
Code: Select all
   function make_keywords($text) {
      $keywords = '';
      $num = 0;
        $stopwords = array("/^about$/","/^1$/","/^after$/","/^2$/","/^all$/","/^also$/","/^3$/","/^an$/","/^4$/","/^and$/","/^5$/","/^another$/","/^6$/","/^any$/","/^7$/","/^are$/","/^8$/","/^as$/","/^9$/","/^at$/","/^0$/","/^be$/","/^$$/","/^because$/","/^been$/","/^before$/","/^being$/","/^between$/","/^both$/","/^but$/","/^by$/","/^came$/","/^can$/","/^come$/","/^could$/","/^did$/","/^do$/","/^each$/","/^for$/","/^from$/","/^get$/","/^got$/","/^has$/","/^had$/","/^he$/","/^have$/","/^her$/","/^here$/","/^him$/","/^himself$/","/^his$/","/^how$/","/^if$/","/^in$/","/^into$/","/^is$/","/^it$/","/^like$/","/^make$/","/^many$/","/^me$/","/^might$/","/^more$/","/^most$/","/^much$/","/^must$/","/^my$/","/^never$/","/^now$/","/^of$/","/^on$/","/^only$/","/^or$/","/^other$/","/^our$/","/^out$/","/^over$/","/^said$/","/^same$/","/^see$/","/^should$/","/^since$/","/^some$/","/^still$/","/^such$/","/^take$/","/^than$/","/^that$/","/^the$/","/^their$/","/^them$/","/^then$/","/^there$/","/^these$/","/^they$/","/^this$/","/^those$/","/^through$/","/^to$/","/^too$/","/^under$/","/^up$/","/^very$/","/^was$/","/^way$/","/^we$/","/^well$/","/^were$/","/^what$/","/^where$/","/^which$/","/^while$/","/^who$/","/^with$/","/^would$/","/^you$/","/^your$/","/^а$/","/^безо$/","/^более$/","/^будем$/","/^будет$/","/^будто$/","/^буду$/","/^будут$/","/^бы$/","/^были$/","/^было$/","/^быть$/","/^в$/","/^в отношении$/","/^в течении$/","/^вас$/","/^ваш$/","/^вблизи$/","/^вбок$/","/^ввосьмером$/","/^в-восьмых$/","/^ввысь$/","/^вдали$/","/^вдаль$/","/^вдвое$/","/^вдвоем$/","/^вдвойне$/","/^вдевятером$/","/^в-девятых$/","/^вдесятеро$/","/^вдогон$/","/^вдогонку$/","/^вдоль$/","/^вдосталь$/","/^вдруг$/","/^верх$/","/^весь$/","/^взамен$/","/^вид$/","/^видно$/","/^вкратце$/","/^вкупе$/","/^вместо$/","/^вне$/","/^внешне$/","/^вниз$/","/^внизу$/","/^вновь$/","/^внутри$/","/^внутрь$/","/^во$/","/^во время$/","/^вовне$/","/^вовсе$/","/^вовсю$/","/^во-первых$/","/^воз$/","/^возле$/","/^воочию$/","/^вопреки$/","/^вот$/","/^впредь$/","/^в-пятых$/","/^вровень$/","/^врознь$/","/^врозь$/","/^вряд ли$/","/^в-седьмых$/","/^все$/","/^всего$/","/^все-таки$/","/^вслед$/","/^всплошную$/","/^вспять$/","/^всюду$/","/^в-третьих$/","/^в-шестых$/","/^вы$/","/^выше$/","/^где$/","/^где-либо$/","/^где-нибудь$/","/^где-то$/","/^да$/","/^дабы$/","/^далее$/","/^де$/","/^для$/","/^до$/","/^другие$/","/^других$/","/^его$/","/^едва$/","/^едва-едва$/","/^ее$/","/^еле$/","/^если$/","/^есть$/","/^еще$/","/^ж$/","/^же$/","/^за$/","/^заключается$/","/^зато$/","/^зачем$/","/^зачем-либо$/","/^зачем-нибудь$/","/^зачем-то$/","/^и$/","/^из$/","/^из-за$/","/^или$/","/^имеющее$/","/^имеющие$/","/^имеющий$/","/^имеющим$/","/^иначе$/","/^итого$/","/^их$/","/^к$/","/^как$/","/^как-либо$/","/^как-нибудь$/","/^какой$/","/^какой-то$/","/^как-то$/","/^кверху$/","/^ко$/","/^когда$/","/^когда-либо$/","/^когда-нибудь$/","/^когда-то$/","/^кое$/","/^кое-где$/","/^кое-как$/","/^кое-какой$/","/^кое-когда$/","/^кое-кто$/","/^кое-куда$/","/^кое-откуда$/","/^кое-чей$/","/^кое-что$/","/^который$/","/^который$/","/^который-либо$/","/^который-нибудь$/","/^кто-либо$/","/^кто-нибудь$/","/^кто-то$/","/^куда$/","/^куда-либо$/","/^куда-нибудь$/","/^куда-то$/","/^ли$/","/^либо$/","/^ль$/","/^мало$/","/^меж$/","/^мимо$/","/^может$/","/^можно$/","/^мы$/","/^на$/","/^над$/","/^надо$/","/^намного$/","/^наш$/","/^не$/","/^него$/","/^некий$/","/^некогда$/","/^некого$/","/^некто$/","/^нем$/","/^немало$/","/^немного$/","/^несколько$/","/^нет$/","/^нечего$/","/^ни$/","/^нигде$/","/^никакой$/","/^никогда$/","/^никто$/","/^никуда$/","/^ним$/","/^нисколько$/","/^ничей$/","/^ничто$/","/^но$/","/^о$/","/^об$/","/^обе$/","/^обо$/","/^однако$/","/^около$/","/^он$/","/^она$/","/^они$/","/^опять$/","/^особенно$/","/^от$/","/^от$/","/^откуда$/","/^откуда-либо$/","/^откуда-нибудь$/","/^откуда-то$/","/^относится$/","/^относятся$/","/^отнюдь$/","/^ото$/","/^отсюда$/","/^оттого$/","/^по$/","/^под$/","/^подле$/","/^подо$/","/^подчас$/","/^позднее$/","/^позже$/","/^пока$/","/^полно$/","/^помимо$/","/^поначалу$/","/^понемногу$/","/^по-прежнему$/","/^порой$/","/^по-своему$/","/^поскольку$/","/^после$/","/^посредине$/","/^постольку$/","/^потом$/","/^потому$/","/^почему$/","/^почему-либо$/","/^почему-нибудь$/","/^почему-то$/","/^почти$/","/^поэтому$/","/^пред$/","/^предо$/","/^представляет$/","/^прежде$/","/^при$/","/^про$/","/^просто$/","/^против$/","/^прямо$/","/^путем$/","/^путем$/","/^ради$/","/^разве$/","/^разом$/","/^ранее$/","/^с$/","/^себе$/","/^сквозь$/","/^сколь$/","/^сколько$/","/^сколько-нибудь$/","/^сколько-то$/","/^сложно$/","/^служащее$/","/^служащие$/","/^служащим$/","/^служит$/","/^сначала$/","/^снова$/","/^со$/","/^собой$/","/^совсем$/","/^содержащее$/","/^содержащий$/","/^содержит$/","/^сообразно$/","/^сперва$/","/^спереди$/","/^сразу$/","/^среди$/","/^средь$/","/^столь$/","/^столько$/","/^та$/","/^так$/","/^такой$/","/^так как$/","/^так что$/","/^также$/","/^там$/","/^то$/","/^тогда$/","/^того$/","/^тоже$/","/^только$/","/^том$/","/^тот$/","/^тут$/","/^у$/","/^уже$/","/^хоть$/","/^хотя$/","/^чего$/","/^чего-то$/","/^чей$/","/^чей-либо$/","/^чей-нибудь$/","/^чей-то$/","/^чем$/","/^через$/","/^что$/","/^что-либо$/","/^что-нибудь$/","/^что-то$/","/^чтоб$/","/^чтобы$/","/^чуть$/","/^чье-либо$/","/^чье-нибудь$/","/^чье-то$/","/^эти$/","/^этим$/","/^этих$/","/^это$/","/^этом$/","/^я$/","/^этот$/","/^оно$/");
      $text = preg_replace(array('`&(amp;)?#?[a-z0-9]+;`i', '`[[:punct:]]+`', '`[\s]+`'), ' ', strip_tags($text) );
      $text = explode(' ', $text);
      // We take the most used words first
      $text = array_count_values($text);
      arsort($text);
      foreach ($text as $word => $count) {
         if ( utf8_strlen($word) > $this->mconfig['wordminlen'] ) {
            $word = preg_replace($stopwords,"",$word);
            if ($word!="") {
                $keywords .= empty($keywords) ? $word : ', ' . $word;
                $num++;
                if ( $num >= $this->mconfig['keywordlimit'] ) {   
                   break;
                }
             }
         }   
      }
      return $keywords;
   }

This code based on this material: http://startrekguide.com/community/view ... =80#p66834
In this case: $stopwords array include ignored words (StopWords) in English and Russia language. You may use any UTF-8 charset.
You may replace $stopwords to your StopWords.

And I change viewtopic.php:
Code: Select all
   $message = censor_text($row['post_text']);
   // www.phpBB-SEO.com SEO TOOLKIT BEGIN  - META
   if ($i == 0) {
      $m_kewrd = '';
      $seo_meta->meta['meta_desc'] = $seo_meta->meta_filter_txt($message);
      if ($seo_meta->mconfig['topic_sql']) {
         $sql = "SELECT w.word_text
            FROM " . SEARCH_WORDMATCH_TABLE . " m, " . SEARCH_WORDLIST_TABLE . " w
            WHERE m.post_id = {$row['post_id']}
               AND w.word_id = m.word_id
               AND w.word_common = 0
            ORDER BY w.word_count DESC";
         if( ($result = $db->sql_query_limit($sql, 3*$seo_meta->mconfig['keywordlimit'])) ) {
            while ( $meta_row = $db->sql_fetchrow($result) ) {
               $m_kewrd .= ' ' . $meta_row['word_text'];
            }
         }
         $db->sql_freeresult($result);
      }
      $seo_meta->meta['keywords'] = !empty($m_kewrd) ? $seo_meta->make_keywords( $m_kewrd ) : $seo_meta->make_keywords($seo_meta->meta['meta_desc']);
   }
   // www.phpBB-SEO.com SEO TOOLKIT END  - META

Most interesting: 3*$seo_meta->mconfig['keywordlimit']
Changes in viewtopic - is only experiment now. But changes in functions.php work correctly IMHO.

What you mind about my modification?
Maybe dcz include this modification in PHPbb3 Premod?
My English not correct - Sorry.

Have a nice day
kar
 
Posts: 9
Joined: Thu May 29, 2008 11:26 am

Advertisement

Postby dcz » Sun Nov 09, 2008 9:22 am

Well, we've just released a more general way of doing this in the 0.2.6 meta tag mod which was just released : http://www.phpbb-seo.com/boards/phpbb3- ... t1308.html

Take a look at this thread too : http://www.phpbb-seo.com/boards/phpbb3- ... t3472.html
Will tell you how to directly filter the unwanted words while indexing.

;)
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21428
Joined: Fri Apr 28, 2006 9:03 pm


Return to phpBB SEO MODS

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 2 guests