ebchost Posted November 24, 2011 Share Posted November 24, 2011 I have web page with very short news ( http://www.sportskevesti.co ) and i have problem to automaticly generate keyword for them (i have to many, over 1000 per day) For example, this is one short news: Brazilski napadač Bruno Mezenga je, na četvrtfinalnom meču Kupa sa Smederevom, ušao je u istoriju Crvene zvezde pogotkom koji može da uđe u konkurenciju za najatraktivnije individualne poteze crveno-belih na beogradskoj Marakani. this is topic of the news POGLEDAJTE KAKO JE MEZENGA DAO JEDAN OD NAJATRAKTIVNIJIH GOLOVA NA MARAKANI /VIDEO/ I want to make sample keyword generator. How to separate from text word shorter then 3 letters and make new string without them? Quote Link to comment https://forums.phpfreaks.com/topic/251718-sample-keyword-generator/ Share on other sites More sharing options...
jcbones Posted November 24, 2011 Share Posted November 24, 2011 There are many ways to do this, one of them being. <?php $str = 'POGLEDAJTE KAKO JE MEZENGA DAO JEDAN OD NAJATRAKTIVNIJIH GOLOVA NA MARAKANI /VIDEO/'; //string to match $patt = '~[a-zA-Z]{3,}~'; //matching pattern; preg_match_all($patt,$str,$match); //preg match ALL, (preg match will only return one word). echo implode(' ',$match[0]); //stick the pieces back together on a space. ?> Quote Link to comment https://forums.phpfreaks.com/topic/251718-sample-keyword-generator/#findComment-1290928 Share on other sites More sharing options...
ebchost Posted November 24, 2011 Author Share Posted November 24, 2011 I managed the show word with more than 4 letters, but I failed to show repeated words, for example the word Beckham (see second part of the code, below echo "$rezultat <hr>"; line) <?php $str = 'Leonardo potvrdio da pregovara sa Bekamom Sportski direktor Pari Sen Zermena Leonardo potvrdio je da taj klub pregovara sa engleskim fudbalerom Dejvidom Bekamom o transferu.'; //string to match $patt = '~[a-zA-Z]{4,}~'; //matching pattern; preg_match_all($patt,$str,$match); //preg match ALL, (preg match will only return one word). $rezultat = implode(' ',$match[0]); //stick the pieces back together on a space. echo "$rezultat <hr>"; function repeated($rezultat) { $rezultat=trim($rezultat); echo "rezultat je $rezultat<hr>"; $str=ereg_replace('[[:space:]]+', ' ',$rezultat); $words=explode(' ',$rezultat); foreach($words as $w) { $wordstats[($w)]++; } foreach($wordstats as $k=>$v) { if($v>=2) { print "$k"." , "; } } } ?> Wer is the problem ? Quote Link to comment https://forums.phpfreaks.com/topic/251718-sample-keyword-generator/#findComment-1290942 Share on other sites More sharing options...
jcbones Posted November 24, 2011 Share Posted November 24, 2011 1. you never called the function repeated(). 2. you are using the depreciated function "ereg()". preg_replace('~\s{2,}~',' ',$str); Quote Link to comment https://forums.phpfreaks.com/topic/251718-sample-keyword-generator/#findComment-1290945 Share on other sites More sharing options...
ebchost Posted November 24, 2011 Author Share Posted November 24, 2011 1. you never called the function repeated(). 2. you are using the depreciated function "ereg()". preg_replace('~\s{2,}~',' ',$str); oooo, thanks spead is not my frend It is obvious that i never calld the function )) my mistake, sorry )) Q: 1. How separate word with first big letter ? (i stil have one important word or phrase "Paris Sen Zermen" - this is name of the Football club) 2. How to show word phrase ? (if that is posible) Quote Link to comment https://forums.phpfreaks.com/topic/251718-sample-keyword-generator/#findComment-1290949 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.