I'm sure you could do it with PHP or another scripting language. I know that php has a str_word_count function. You could definately use that to count the number of words, define what your density is and iterate through the list and place your phrase as you want. There may be a quicker and cleaner way of doing it, but that's the first thing that came to my mind.