First cut of parsing complex sentences
This commit is contained in:
parent
b99442949d
commit
202d06a19d
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
(define adjectives '(adjective happy lazy))
|
(define adjectives '(adjective happy lazy))
|
||||||
|
|
||||||
|
(define connectives '(and but or))
|
||||||
|
|
||||||
;; output of parse
|
;; output of parse
|
||||||
'(sentence (noun-phrase (article the) (noun cat))
|
'(sentence (noun-phrase (article the) (noun cat))
|
||||||
(verb eats))
|
(verb eats))
|
||||||
|
@ -48,11 +50,20 @@
|
||||||
(parse-word prepositions)
|
(parse-word prepositions)
|
||||||
(parse-noun-phrase)))
|
(parse-noun-phrase)))
|
||||||
|
|
||||||
(define (parse-sentence)
|
(define (parse-simple-sentence)
|
||||||
(list 'sentence
|
(list 'simple-sentence
|
||||||
(parse-noun-phrase)
|
(parse-noun-phrase)
|
||||||
(parse-verb-phrase)))
|
(parse-verb-phrase)))
|
||||||
|
|
||||||
|
(define (parse-sentence)
|
||||||
|
(define (maybe-extend sentence)
|
||||||
|
(amb sentence
|
||||||
|
(maybe-extend (list 'compound-sentence
|
||||||
|
sentence
|
||||||
|
(parse-word connectives)
|
||||||
|
(parse-simple-sentence)))))
|
||||||
|
(maybe-extend (parse-simple-sentence)))
|
||||||
|
|
||||||
(define (parse-verb-phrase)
|
(define (parse-verb-phrase)
|
||||||
(define (maybe-extend verb-phrase)
|
(define (maybe-extend verb-phrase)
|
||||||
(amb verb-phrase
|
(amb verb-phrase
|
||||||
|
|
Loading…
Reference in New Issue