Thread: Keyword Maker CFC
KaptainKrayola

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!

<!--- 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>

perkiset

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?

KaptainKrayola

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:


<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:

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?

perkiset

Beautious! thanks Kapn

nop_90

Applause

flak88

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

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.  Applause

KaptainKrayola

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!

perkiset

Applause so a CF server is still a paid-for thang, eh?

KaptainKrayola

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.

perkiset

I'm amazed that they can still compete in an

Apache

 /

PHP

 /

Python

 /

PERL

  world... do you see CF as a dead mechanism walking?

flak88

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.

KaptainKrayola

quote author=perkiset link=topic=152.msg972#msg972 date=1178386184

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.

quote author=flak88 link=topic=152.msg973#msg973 date=1178386403

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

thedarkness

quote author=KaptainKrayola link=topic=152.msg974#msg974 date=1178386695

If anyone has any questions please let the <>Admiral Kaptain Know


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

Cheers,
td

nop_90

quote author=flak88 link=topic=152.msg962#msg962 date=1178363422

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

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 Applause


Perkiset's Place Home   Politics @ Perkiset's