Beispiel #1
0
        def setUp2():

                lex = XMLLexicon()

                #my dog's my best friend        
                s1 = Clause()
                a = "my best friend"

                s1 = NounPhrase(a)
                np_own = s1.add_owner(lex.getWord("dog"))
                np_own.add_determiner(lex.getWord("my"))
                
                print(s1.realize())
Beispiel #2
0
        def setUp1():

                lex = XMLLexicon()

                #the girl is playing the guitar        
                s1 = Clause()
                
                np_sub = s1.add_subject(lex.getWord("girl"))
                np_sub.add_determiner(lex.getWord("the"))
                vp_play = s1.add_verb(lex.getWord("play", "VERB"))
        
                np_guitar = vp_play.add_object(lex.getWord("guitar"))
                np_guitar.add_determiner(lex.getWord("the"))
        
                s1.set_verb_tense("present_progressive")

                print(s1.realize())
Beispiel #3
0
        def setUp3():

                lex = XMLLexicon()

                #put the beans in the old machine
                s1 = ImperativeClause()

                vp_put = s1.add_verb(lex.getWord("put", "VERB"))
                np_the_machine = NounPhrase(lex.getWord("machine", "NOUN"), determiner=lex.getWord("the"), adjectives=[lex.getWord("old")])
                pp_in_the_machine = PrepositionalPhrase(lex.getWord("in", "PREPOSITION"), [np_the_machine])
        
                vp_put.add_prepositional_phrase(pp_in_the_machine)
        
        
                np_the_beans = s1.add_subject(lex.getWord("bean"))
                np_the_beans.add_determiner(lex.getWord("the"))
                np_the_beans.set_number("plural")

                print(s1.realize())
Beispiel #4
0
def setUp1(noun, verb, obj, tense):
	lex = XMLLexicon()  
	#the girl is playing the guitar        
	s1 = Clause()
	try:
		np_sub = s1.add_subject(lex.getWord(noun,"NOUN"))
		np_sub.add_determiner(lex.getWord("the")) 
		vp_play = s1.add_verb(lex.getWordFromVariant(verb, "VERB"))

		#if none
		np_guitar = vp_play.add_object(lex.getWord(obj,"NOUN"))
		np_guitar.add_determiner(lex.getWord("the"))
		s1.set_verb_tense(tense)
		print(s1.realize())

	except :
		try:
			np_sub = s1.add_subject(Noun(noun))
			np_sub.add_determiner(lex.getWord("the"))
			vp_play = s1.add_verb(lex.getWordFromVariant(verb,"VERB"))

			#if none
			np_guitar = vp_play.add_object(Noun(obj))
			np_guitar.add_determiner(lex.getWord("the"))
			s1.set_verb_tense(tense)
			print(s1.realize())
		except Exception as inst:
			print(type(inst))
			print(inst.args)
			pass
Beispiel #5
0
        def setUp4():

                lex = XMLLexicon()
        
                #the woman kissed the man behind the curtain
                s1 = Clause()

                np_woman = s1.add_subject(lex.getWord("woman"))
                np_woman.add_determiner(lex.getWord("the"))
                                
                vp_kiss = s1.add_verb(lex.getWord("kiss", "VERB"))
                np_the_curtain = NounPhrase(lex.getWord("curtain", "NOUN"), determiner=lex.getWord("the"))
                pp_the_curtain = PrepositionalPhrase(lex.getWord("behind", "PREPOSITION"), [np_the_curtain])
        
                vp_kiss.add_prepositional_phrase(pp_the_curtain)
        
                np_man = vp_kiss.add_object(lex.getWord("man"))
                np_man.add_determiner(lex.getWord("the"))
                
        
                s1.set_verb_tense("past")

                print(s1.realize())
Beispiel #6
0
 def setUp(self):
     lex = XMLLexicon()
     
     #the woman kissed the man behind the curtain
     self.s1 = Clause()
     np_woman = self.s1.add_subject(lex.getWord("woman"))
     np_woman.add_determiner(lex.getWord("the"))
     vp_kiss = self.s1.add_verb(lex.getWord("kiss", "VERB"))
     
     np_man = vp_kiss.add_object(lex.getWord("man"))
     np_man.add_determiner(lex.getWord("the"))
     
     self.s1.set_verb_tense("past")
     
     
     #there is the dog on the rock
     
     #the man gives the woman John's flower
     self.s2 = Clause()
     np_man = self.s2.add_subject(lex.getWord("man"))
     np_man.add_determiner(lex.getWord("the"))
     
     vp_give = self.s2.add_verb(lex.getWord("give"))
     vp_give.set_tense("present")
     
     np_flower = vp_give.add_object(lex.getWord("flower"))
     np_flower.add_owner(lex.getWord("john"))
     
     np_woman = vp_give.add_indirect_object(lex.getWord("woman"))
     np_woman.add_determiner(lex.getWord("the"))
     
     #Test imperative
     
     #Make the coffee
     
     self.s3 = ImperativeClause()
     vp_make = self.s3.add_verb(lex.getWord("make", "VERB"))
     np_the_coffee = self.s3.add_subject(lex.getWord("coffee"))
     np_the_coffee.add_determiner(lex.getWord("the"))
     
     #Put the beans in the machine
     self.s4 = ImperativeClause()
     vp_put = self.s4.add_verb(lex.getWord("put", "VERB"))
     np_the_machine = NounPhrase(lex.getWord("machine", "NOUN"), determiner=lex.getWord("the"))
     pp_in_the_machine = PrepositionalPhrase(lex.getWord("in", "PREPOSITION"), [np_the_machine])
     
     vp_put.add_prepositional_phrase(pp_in_the_machine)
     
     
     np_the_beans = self.s4.add_subject(lex.getWord("bean"))
     np_the_beans.add_determiner(lex.getWord("the"))
     np_the_beans.set_number("plural")