(include "lib/lisp-macro.scm")
(include "lib/fail.scm")
(include "lib/interlace.scm")
(include "lib/bot.scm")
(include "lib/struct.scm")
(include "lib/verb.scm")

(define (forms fn vb . args)
  (list->vector (map (lambda (a) (fn vb a)) args)))

(define (flexprep vb . args)
		  (list->vector
			(append (map (lambda (x) postpositive vb x) args)
					(map (lambda (x) phrase vb x) args))))


(define intransitive-verbs (interlace vector
	(forms phrase
		   (verb:strong "get" "got" "gotten") "up" "off" "out")
	(verb:weak "leak")
	(verb:weak "scream")
	(verb:weak "fear")
	hurt. (verb:strong! "hurt" "hurt")
	(forms postpositive
		   hurt "bad" "real bad" "like hell"
		   "something awful" "something fierce"
		   "something terrible" "real good")

	(forms postpositive
		   (verb:weak "jerk") "it" "off")

	(forms phrase (verb:strong "throw" "threw" "thrown")
			"up" "down")
	))

(define vocab:roa-verbs (interlace vector
	get. (verb:strong "get" "got" "gotten")
		(forms phrase
			get "up" "off" "out" "in")
		(forms postpositive
		   get "in" "in on" "out of" "up in" "into"
		   "off on" "over" "over to")
	crunch. (verb:weak "crunch")
		(flexprep crunch "up" "off" "out" "away")
		(postpositive crunch "on")
	cyber. (verb:weak "cyber")
		(flexprep cyber "up")
	slurp. (verb:weak "slurp")
		(flexprep "up")
	suck. (verb:weak "suck")
		(flexprep suck "up" "off" "down")
	throw. (verb:strong "throw" "threw" "thrown")
		(flexprep throw "up")
		(postpositive throw "back")
	chew. (verb:weak 	"chew")
		(flexprep chew "up")
		(postpositive chew "on")
	have. (verb:irregular "have" "has" "having" "had" "had")
	do. (verb:irregular "do" "does" "doing" "did" "done")
	poop. (verb:weak "poop")
		(flexprep poop "out")
		(postpositive poop "on")
	piss. (verb:weak "piss")
		(postpositive piss "on")
		(flexprep piss "out" "away" "off")
	cook. (verb:weak "cook")
		(phrase cook "up")
	tweet. (verb:weak "tweet")
		(forms phrase tweet "up" "at")
	plug. (verb:heavy "plug" "g")
		(phrase plug "in")
	(postpositive (verb:weak "laugh") "at")
	(flexprep (verb:weak "hook") "up" "in")
	(flexprep (verb:weak "turn") "on" "in")

	(verb:weak	"download")
	(verb:weak	"snort")
	(verb:weak	"sniff")
	(verb:weak 	"down")
	(verb:weak 	"hoot")
	(verb:weak 	"toot")
	(verb:weak 	"boof")
	(verb:weak 	"blast")
	(verb:weak 	"honk")
	(verb:weak 	"whack")
	(verb:weak 	"loot")
	(verb:weak 	"slaughter")
	(verb:weak 	"ghoul")
	(verb:es 	"ravish")
	(verb:es	"piss")
	(verb:es	"crunch")
	(verb:e	 	"scrobbl")
	(verb:e	 	"chok")
	(verb:e	 	"blaz")
	(verb:e	 	"freebas")
	(verb:e	 	"us")
	(verb:e		"vap")
	(verb:e	 	"smoke")
	(verb:e	 	"gargle")
	(verb:e	 	"guzzle")
	(verb:e		"mainlin")
	(verb:y 	"tr")
	(verb:heavy	"stab" "b")
	(verb:heavy "pop" "p")
	(verb:heavy	"zap" "p")
	(verb:heavy	"slug" "g")
	(verb:strong "drink" "drank"	"drunk")
	(verb:strong "eat"   "ate"		"eaten")
	(verb:strong "bite"  "bit"		"bitten")

	shoot. (verb:strong!	"shoot" "shot")
	(phrase shoot "up")))

(define person     (struct '1sg '1pl '2 '3sg.f '3sg.m '3pl 'inan))
(define declension (struct 'nom 'acc 'gen 'poss 'refl 'cop))
(define pronoun (apply person (map declension '(
	  ("i"    "me"   "my"    "mine"   "myself"	   "i'm"
	  ("we"   "us"   "our"   "our"    "ourself"	   "we're") 
	  ("you"  "you"  "your"  "yours"  "yourself"   "you're")  
	  ("she"  "her"  "her"   "hers"   "herself"	   "she's")   
	  ("he"   "him"  "his"   "his"    "himself"	   "he's")
	  ("they" "them" "their" "theirs" "themselves" "they're" )
	  ("it"   "it"   "its"   "its"    "itself"     "it's" ))))))

(define (look-up st . path)
  (if (eq? '() (cdr path)) (st (car path))
	  (look-up (st (car path)) (cdr path))))
  

(define collapse-person (person '1sg 'pl '3sg '3sg 'pl))
; not all person forms are contrastive in english; this
; way we only have to encode the ones that contrast

; state: a function that is called on a person, a tense
; (one of 'pst 'prs 'fut 'perf 'imperf), an aspect
; ('stat 'inch), and returns a string of text describing
; the person in that state
;  e.g.	(outta-mind '3sg.f 'prs 'stat) → "is outta her mind"
;		(suicidal '3sg.m 'fut 'stat) → "is gonna want to die"

; (define (adjective pers tense aspect))


(define (pick-rec top-list)  ; note: do not expose to
  (let ([e (pick top-list)]) ; empty vectors
	(if (vector? e) (pick-rec e) e)))

(define verb:be (let ([t (struct 'inf 'pst)]
					  [p (struct '1sg '3sg 'pl)])
				  (t (p "am"  "is" "are")
					 (p "was" "was" "were"))))


(define noun:sg   (vector "a" "the" "this"))
(define noun:pl   (vector "" "the" "these"))
(define noun:mass (vector "" "the" "this"))
(define noun:pn   (vector ""))

(define nouns
  (let* ([$ string-append] [: cons] [@ list]
		 [~		(lambda (str lst) (list->vector (map (lambda (fn) (fn str)) lst)))]
		 [sg	(lambda (n) (: n				noun:sg))]
		 [pl	(lambda (n) (: ($ n "s")		noun:pl))]
		 [pl/s	(lambda (n) (: ($ n "es")		noun:pl))]
		 [pl/i	(lambda (p) (lambda (_) (: p	noun:pl)))]
		 [pl/iso(lambda (n) (: n				noun:pl))]
		 [mass	(lambda (n) (: n				noun:mass))]
		 [mass/i(lambda (m) (lambda (_) (: m	noun:mass)))]
		 [pn	(lambda (n) (: n				noun:pn))])
	(vector
	  (~ "water"	[@ mass pl])
	  (~ "shoe"		[@ sg pl])
	  (~ "man"		[@ sg (pl/i "men") (mass/i "Man")])
	  (~ "mouth"	[@ sg pl])
	  (~ "ass"		[@ sg pl/s])
	  (~ "dick"		[@ sg pl mass])
	  (~ "cock"		[@ sg pl mass])
	  (~ "cunt"		[@ sg pl mass])
	  (~ "pussy"	[@ sg mass (pl/i "pussies")])
	  (~ "eyeball"	[@ sg pl])
	  (~ "bed"		[@ sg pl])
	  (~ "house"	[@ sg pl])
	  (~ "home"		[@ mass pl])
	  (~ "pants"	[@ pl/iso])
	  (~ "face"		[@ sg pl])
	  (~ "friend"	[@ sg pl])
	  (~ "pal"		[@ sg pl])
	  (~ "buddy"	[@ sg (pl/i "buddies")])
	  (~ "vomit"	[@ mass])
	  (~ "phone"	[@ sg pl])
	  (~ "pig"		[@ sg pl])
	  (~ "cop"		[@ sg pl])
	  (~ "human"	[@ sg pl])
	  (~ "God"		[@ pn])
	  (~ "god"		[@ sg pl])
	  (~ "goddess"	[@ sg pl/s])
	  (~ "asshole"	[@ sg pl])
	  (~ "clown"	[@ sg pl])
	  (~ "fear"		[@ mass])
	  (~ "person"	[@ sg (pl/i "people")]))))
; TODO: second-order verbs
#|
(define (verb-phrase tense noun)
  (let* ([verb (pick-rec transitive-verbs)]
		 [noun-form (pick noun)]
		 [det (pick (cdr noun-form))]
		 [bare-noun (car noun-form)])
	((verb tense) (word-append det bare-noun))))

(define (mod-noun noun)
  (let* ([mode (one-of (cons transitive-verbs 'ppl)
					   (cons intransitive-verbs 'adj))]
		 [noun-form (pick noun)]
		 [bare-noun (car noun-form)]
		 [verb (pick-rec (car mode))]
		 [vbd-noun ((verb (cdr mode)) bare-noun)])
	(vector (cons vbd-noun (cdr noun-form)))))

(print "in this house, we " (verb-phrase 'inf (mod-noun (pick nouns))))
(exit 0)
|#
