nlp - Natural Language Generation in PHP -


i woke last night thought in head: can php used generate random words sound natural? (like lorem ipsum verses).

  1. words being single letter: 'a,e,i,o,u'
  2. words being double letter: combination of vowel , consonant.
  3. maximum word length think 6 letters.

the purpose fill space on website templates instead of 'lorem ipsum', or send test emails php scripts make sure mail() works.

but thoughts on how work php generate random length words, 1-6 letters each, few "don't this" rules "no 2 single-letter words next each other" or "no three-vowels in row" or "no three-consonants in row" , automatically add punctuation , capitalization after between 4 , 8 words sentence.

would @ possible, , if so, there pre-existing classes or functions implement?

you can take context-free grammar approach: http://en.wikipedia.org/wiki/context-free_grammar

<word> := <vowel> | <consonant><remaining word following consonant> | <vowel><remaining word following vowel> <vowel> := a|e|i|o|u <consonant> := b|c|d|f|g|... <word following vowel> := <consonant><remaining word following consonant> ...and on 

implement grammar in procedural language (c , php included), start generating words based on grammar.

i don't know of generic php parsing frameworks can @ best practices writing them: best practices writing programming language parser


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -