The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 19, 2019, 05:41:48 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Keyword Maker CFC  (Read 7056 times)
KaptainKrayola
Keeper of Pie
Global Moderator
Lifer
*****
Offline Offline

Posts: 994



View Profile WWW
« on: May 03, 2007, 08:04:12 AM »

The Kaptain wrote this up a while back to make long tail keyword phrases.  You provide it with a list of keywords or phrases, a list of "mix in" words, tell it the maximum number of words you want per phrase, and how many phrases you want it to generate. 

Right now it will generate lists of unique key phrases at about 1k phrases per second.  The more you tell it to generate at once the longer it takes (exponentially) because it only adds keys to the list that are unique.  The Kaptain just had it generate 5k keywords in about a minute on his dev server.

Feel free to update, edit, or delete as you see fit.  If you do improve upon it please post your code back here so the Kaptain can update his as well.

Enjoy!

Code:
<!--- the purpose of this CFC is to build giant lists of keywords out of a few "seeds"
you have to give it a list of keywords (comma seperated), a list of "mixer" words, and how many phrases you want then it will do the rest.
--->

<cfcomponent output="no">
<cffunction name="init" access="public" returntype="string">
<cfargument name="Keys" type="string" required="yes">
<cfargument name="MixerList" type="string" required="yes">
<cfargument name="NumberToGen" type="numeric" required="yes">
<cfargument name="MaxWordsInKey-1" default="5" required="yes" type="numeric">

<cfset var NewKeys = "">

<cfscript>
//we want to use the original list first then mix new words in
origLen = Listlen(arguments.keys);
numToMix = 1; //start with one mix word then we will add more and more as needed
maxToMix = arguments.MaxWordsInKey; //this will tell the script how many mix words to use max.  afterwards it will start splitting up the original words
counter = 1; //start the counter for iterations
listPos = 1;

for(i = 1; i LTE arguments.NumberToGen; i = i + 1) {
useKey = ListGetAt(Keys,listPos);
MixedKey = MixKey(numToMix,arguments.MixerList,useKey);
if (NOT ListFindNoCase(NewKeys,MixedKey)){
NewKeys = ListAppend(NewKeys,MixedKey);
counter = counter + 1;
}

//end of the list?
if (listPos EQ origLen){
listPos = 1; //start again at the beginning

if (numToMix LT maxToMix){
numToMix = numToMix + 1;
}
}
listpos = listpos + 1;
}
</cfscript>

<cfreturn NewKeys>
</cffunction>

<cffunction name="MixKey" returntype="string">
<cfargument name="Mixers" type="numeric" default="1" required="yes">
<cfargument name="MixList" required="yes" type="string">
<cfargument name="keyToMix" required="yes">
<cfargument name="SplitKeys" required="no" default="0">

<cfset var Append = RandRange(0,1)>
<cfset var MixIn = "">

<cfloop from="1" to="#arguments.mixers#" index="x">
<cfset MixIn = MixIn & ' ' & ListGetAt(arguments.mixList,RandRange(1,ListLen(arguments.mixList)))>
</cfloop>

<cfif Append>
<cfset returnThis = MixIn & ' ' & arguments.keyToMix >
<cfelse>
<cfset returnThis =  arguments.keyToMix & ' ' & MixIn>
</cfif>
<!--- trim just in case --->
<cfset ReturnThis = TRIM(returnThis)>

<cfreturn returnThis>

</cffunction>
</cfcomponent>

<edit>
Fixed typo in the code
</edit>
« Last Edit: May 04, 2007, 09:04:18 AM by KaptainKrayola » Logged

We can't stop here, this is bat country.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: May 03, 2007, 03:56:34 PM »

Hey Kaptain -

(Caveat, non-CFr here, just trying to understand)

It looks to me like that is two functions - so where would the "main()" be? Is that a separate page that would (include) then call both of them? It looks as though the Return directive would either output or literally return the keys, but to what?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
KaptainKrayola
Keeper of Pie
Global Moderator
Lifer
*****
Offline Offline

Posts: 994



View Profile WWW
« Reply #2 on: May 04, 2007, 07:48:16 AM »

Being a non-CFer you probably aren't familiar with ColdFusion Components.  You would save the code above in it's own file called KeywordMaker.cfc then you would want to create another file that will use the keywordMaker.cfc.

We will assume you already have the KeywordMaker.cfc saved in a directory and you have created a file in the same directory and entered the following code:

Code:
<cfobject component="KeywordMaker"  name="KeywordMaker" />

<cfscript>
keywords = "beef, chicken, pork, mango, pie, monkey, idiot, perkiset, smells, like, burritos";
mixers = "the, big, small, orange, purple, nice, ugly, fat, hairy, smart, dumb, lost, stolen, found, hated";
keysToMake = 400;
maxWordsPerKey = 5;

NewKeyList = KeywordMaker.init(keywords,mixers,keysToMake,maxWordsPerKey);
</cfscript>

<cfoutput>#NewKeyList#</cfoutput>

Now, if you run this you will get a giant list of unique key phrases based on the 2 lists of words.  Here is an example of the output:

Code:
lost beef,dumb chicken,nice pork,orange mango,lost pie,lost monkey,fat idiot,perkiset found,smells hated,dumb like,burritos fat,chicken lost lost,pork dumb lost,mango lost big,pie orange lost,monkey hairy nice,idiot found hairy,perkiset ugly orange,nice ugly smells,like nice ugly,hairy small burritos,chicken ugly nice hairy,nice stolen hated pork,smart purple fat mango,lost big dumb pie,monkey purple nice found,idiot dumb purple stolen,fat hated hated perkiset,purple nice found smells,stolen ugly purple like,burritos nice hated fat,chicken the dumb big smart,pork nice small hairy hairy,smart dumb fat hated mango,pie dumb ugly orange purple,hairy hated nice nice monkey,purple fat found dumb idiot,dumb hated dumb big perkiset,smells smart orange hated fat,like hated dumb dumb purple,burritos fat fat purple small,chicken found big lost found,small nice dumb stolen pork,mango small dumb fat small,pie nice hated dumb nice,small dumb nice stolen monkey,found fat hairy dumb idiot,perkiset nice big nice stolen,smells small small stolen hairy,hairy purple lost hairy like,burritos lost ugly hairy nice,stolen dumb the fat chicken,pork dumb orange hated found,orange orange big hated mango,pie nice hairy small nice,smart big big ugly monkey,idiot hairy found orange fat,smart ugly dumb purple perkiset,the ugly found the smells,like the stolen the purple,burritos nice fat found hairy,fat ugly lost big chicken,the stolen purple stolen pork,mango dumb purple smart nice,hairy hairy the fat pie,dumb fat stolen found monkey,small big smart hated idiot,small fat smart found perkiset,smells stolen big big fat,found big found nice like,the the smart hairy burritos,chicken big found big hairy,pork purple the fat ugly,mango nice purple nice stolen,pie small hated stolen hated,nice the found small monkey,idiot orange stolen lost big,perkiset found smart purple nice,smells big ugly hated found,like stolen purple orange big,burritos ugly fat big small,chicken purple hated small fat,pork small ugly smart big,nice orange big smart mango,lost hated hated fat pie,monkey the orange lost big,idiot purple ugly nice smart,ugly dumb big nice perkiset,smells hated smart ugly dumb,found fat found stolen like,burritos ugly purple big orange,dumb stolen orange the chicken,pork purple small the the,hairy orange hated found mango,ugly purple hated ugly pie,purple the nice lost monkey,big found smart stolen idiot,the small hairy nice perkiset,smells the dumb hated big,big found hairy lost like,burritos dumb ugly small found,found smart hairy the chicken,pork nice hairy nice lost,mango dumb stolen nice stolen,pie fat found lost hated,stolen hated smart hairy monkey

It returns the keywords as a comma delimited list because ColdFusion has a ton of built in list functions and working with a comma delimited list is really simple.  Makes it easy to operate on in any language though.

Clear as mud?
Logged

We can't stop here, this is bat country.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: May 04, 2007, 09:01:16 AM »

Beautious! thanks Kapn
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #4 on: May 04, 2007, 10:13:45 PM »

 Devilish
Logged
flak88
n00b
*
Offline Offline

Posts: 5



View Profile
« Reply #5 on: May 05, 2007, 04:10:22 AM »

Oh hell do I need this!  My "longtail keyphrase maker" is currently made up of a giant Excel spreadhseet.   ROFLMAO 

You keep posting stuff like this Kaptain and you might get promoted to Commodore.

Ok, I have NEVER used cold fusion.  I do use Dreamweaver MX though, and I think the cd came with some kind of CF server or something I could install locally. 

So how do I set this up and run it?  Can I just run it locally? 

Or do I just need to go to Barnes & Noble and buy a "Cold Fusion for Dummies" book.  I'll put it on the shelf beside my PHP book.   ROFLMAO
Logged

No links in signatures please
KaptainKrayola
Keeper of Pie
Global Moderator
Lifer
*****
Offline Offline

Posts: 994



View Profile WWW
« Reply #6 on: May 05, 2007, 09:59:22 AM »

You can go to adobe.com and download a copy of ColdFusion server.  You can install it as the "developer" edition and it's free (will give you this option instead of entering a serial number).  The developer edition will only work over 127.0.0.1 but it is fully functional.

Enjoy!

Logged

We can't stop here, this is bat country.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #7 on: May 05, 2007, 10:15:55 AM »

 D'oh! so a CF server is still a paid-for thang, eh?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
KaptainKrayola
Keeper of Pie
Global Moderator
Lifer
*****
Offline Offline

Posts: 994



View Profile WWW
« Reply #8 on: May 05, 2007, 10:20:40 AM »

unfortunately, yes.  the Kaptain wonders how much longer they are going to be able to keep their current pricing model with all the competition out there giving their server pieces away for free.

There is a free CF server called Blue Dragon, though.  http://www.newatlanta.com/products/bluedragon/index.cfm

The Kaptain tested it out a couple years ago and it worked pretty well but he can't vouch for it now.
Logged

We can't stop here, this is bat country.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #9 on: May 05, 2007, 10:29:44 AM »

I'm amazed that they can still compete in an Apache/PHP/Python/PERL world... do you see CF as a dead mechanism walking?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
flak88
n00b
*
Offline Offline

Posts: 5



View Profile
« Reply #10 on: May 05, 2007, 10:33:23 AM »

Thanks Admiral uh Kaptain!  Well 127.0.0.1 is all I'll need.  I just need a way to churn out longtails faster and this should be it.
Logged

No links in signatures please
KaptainKrayola
Keeper of Pie
Global Moderator
Lifer
*****
Offline Offline

Posts: 994



View Profile WWW
« Reply #11 on: May 05, 2007, 10:38:15 AM »

I'm amazed that they can still compete in an Apache/PHP/Python/PERL world... do you see CF as a dead mechanism walking?

The Kaptain wouldn't be surprised if they start seeing more and more troubles from the freeware apps considering how widely accepted they are and how expensive CF Server is.  However, one thing they have going for them is the US Army LOVES using CF so they make a ton of sales to the Army.  Don't know about dead but certainly hurting.

Thanks Admiral uh Kaptain!  Well 127.0.0.1 is all I'll need.  I just need a way to churn out longtails faster and this should be it.

That thing will churn them out by the thousands too - works like a charm. 

If anyone has any questions please let the Admiral Kaptain Know
Logged

We can't stop here, this is bat country.
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #12 on: May 05, 2007, 04:32:58 PM »

If anyone has any questions please let the Admiral Kaptain Know

No, shameless self-promotion in these fora thanks. Mods?  ROFLMAO  ROFLMAO  ROFLMAO

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #13 on: May 05, 2007, 06:03:47 PM »

Oh hell do I need this!  My "longtail keyphrase maker" is currently made up of a giant Excel spreadhseet.   ROFLMAO 
I am paraniod in general.
I only run linux but i am always paraniod that someone has gotten behind my NAT is and is hacking my system.
Then i am paranoid that my system will crash the files will get corrupted and i will be unable to recover them, the backup will fail also

So i keep my stuff in text files most of the time Cheesy
Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!