天天看点

计算机生成的简单英文句子

> (define (sentence) (append (noun-phrase) (verb-phrase)))
> (define (noun-phrase) (append (Article) (Noun)))
> (define (verb-phrase) (append (Verb) (noun-phrase)))
> (define (Article) (one-of '(the a)))
> (define (Noun) (one-of '(man ball woman table)))
> (define (Verb) (one-of '(hit took saw liked)))
> (define (one-of set)
    (list (list-ref set (random (length set))))))
> (sentence)
(the table saw the ball)
> (sentence)
(a woman hit a ball)
> (sentence)
(the woman took a man)
> (sentence)
(a table hit the woman)
> (sentence)
(a ball saw the ball)
> (sentence)
(the table liked a woman)
           

继续阅读