First cut of parsing complex sentences

This commit is contained in:
Oliver Payne 2024-01-08 23:00:32 +00:00
parent b99442949d
commit 202d06a19d
1 changed files with 13 additions and 2 deletions

View File

@ -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