OK, spent a little time in this stuff this morning. Here's the MS SQL for the basics, just need to make it recursive for the 3 and 4 word splits. Actually, I think I can make it work for unlimited word counts. This runs in < 1 second per name on my older, stessed server running 13,000 websites.
declare @str varchar(100)
set @str = 'firedepartment'
--set @str = 'CREDITCARDSFORALL'
set @str = lower(@str)
declare @pos1 int, @pos2 int, @done char(1), @word1 varchar(100), @word2 varchar(100), @pos1_stop int
declare @word1_dict int, @word2_dict int
set @done = 'N'
set @pos1 = 0
set @pos2 = 0
set @pos1_stop = len(@str) - 2
while @done='N'
begin
set @word1_dict = 0
set @word2_dict = 0
set @pos1 = @pos1 + 1
set @word1 = substring(@str,1,@pos1)
set @word2 = substring(@str,@pos1+1,100)
if @pos1 = 1
begin
if @word1 = 'a'
set @word1_dict = 1
end
else
begin
select @word1_dict = count(*) from dictionary.dbo.dictionary where @word1 = word
end
if @word1_dict > 0
select @word2_dict = count(*) from dictionary.dbo.dictionary where @word2 = word
-- TODO: recursive check of remainder of string for 2 more words, then 3 more words
-- if @word1_dict > 0 and @word2_dict > 0
-- TODO: Insert into DB for Google pop check if more than one result
-- Test-only Check of results
select @pos1, @word1, @word1_dict, @word2, @word2_dict
if @pos1 = @pos1_stop
set @done = 'Y'
end