-
Notifications
You must be signed in to change notification settings - Fork 6
/
test6
executable file
·32 lines (25 loc) · 967 Bytes
/
test6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env scheme-script
(import (rnrs) (stochastic-recognizer))
(define (with-a-telescope n)
(if (zero? n) '() (append '(p det n) (with-a-telescope (- n 1)))))
(define (grammatical-hard-sentence n)
`(det n v det n ,@(with-a-telescope n)))
(define (ungrammatical-hard-sentence n)
`(det n v det n ,@(with-a-telescope n) v))
(define *production-distributions*
(list (cons (make-production 's 'np 'vp) 1.0)
(cons (make-production 'vp 'v 'np) 0.5)
(cons (make-production 'vp 'v 's) 0.25)
(cons (make-production 'vp 'vp 'pp) 0.25)
(cons (make-production 'np 'np 'pp) 0.5)
(cons (make-production 'np 'det 'n) 0.5)
(cons (make-production 'pp 'p 'np) 1.0)))
(write (phrase-probability3
(grammatical-hard-sentence 13) 's *production-distributions*))
(newline)
(write (phrase-probability3
(ungrammatical-hard-sentence 13) 's *production-distributions*))
(newline)
;;; Local Variables:
;;; eval: (scheme-mode)
;;; End: