예제 #1
0
파일: Sample2.py 프로젝트: johndpope/SumMe
    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())
예제 #2
0
파일: Sample2.py 프로젝트: ellej16/SumMe
        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())
예제 #3
0
파일: Sample.py 프로젝트: johndpope/SumMe
def setUp():

	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("abandon", "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())
예제 #4
0
def setUp1(noun, verb, obj):

    lex = XMLLexicon()
    #the girl is playing the guitar
    s1 = Clause()

    np_sub = s1.add_subject(lex.getWord("girl"))
    np_sub = s1.add_subject(lex.getWord(noun, "NOUN"))
    np_sub.add_determiner(lex.getWord("the"))
    vp_play = s1.add_verb(lex.getWord(verb, "VERB"))

    np_guitar = vp_play.add_object(lex.getWord(obj))
    np_guitar.add_determiner(lex.getWord("the"))

    s1.set_verb_tense("present_progressive")

    print(s1.realize())
예제 #5
0
파일: Sample2.py 프로젝트: johndpope/SumMe
    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())
예제 #6
0
파일: Sample.py 프로젝트: cl4rke/SumMe
def setUp():
        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_man = vp_kiss.add_object(lex.getWord("man"))
        np_man.add_determiner(lex.getWord("the"))
        
        s1.set_verb_tense("past")       
        print(s1.realize())
예제 #7
0
파일: Sample3.py 프로젝트: ellej16/SumMe
def setUp1(noun, verb, obj):


	lex = XMLLexicon()  
	#the girl is playing the guitar        
	s1 = Clause()

	np_sub = s1.add_subject(lex.getWord("girl"))
	np_sub = s1.add_subject(lex.getWord(noun,"NOUN"))
	np_sub.add_determiner(lex.getWord("the"))
	vp_play = s1.add_verb(lex.getWord(verb, "VERB"))

	np_guitar = vp_play.add_object(lex.getWord(obj))
	np_guitar.add_determiner(lex.getWord("the"))

	s1.set_verb_tense("present_progressive")

	print(s1.realize())
예제 #8
0
파일: Sample2.py 프로젝트: ellej16/SumMe
        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())
예제 #9
0
 def setUp(self):
     #A young girl with red hair and green eyes is sitting in one of three chairs by the fireplace in the northern part of this room.
     lex = XMLLexicon("C:/projects/Python-nlg/res/default-lexicon.xml")
     self.np_a_young_girl = NounPhrase(lex.getWord("girl"), determiner = lex.getWord("a"), adjectives=[lex.getWord("young")])
     self.np_red_hair = NounPhrase(lex.getWord("hair"), adjectives=[lex.getWord("red", "ADJECTIVE")])
     self.np_glasses = NounPhrase(lex.getWord("glasses"))
     
     
     self.pp_with_red_hair_and_glasses = PrepositionalPhrase(lex.getWord("with"), [self.np_red_hair, self.np_glasses])
     
     self.np_the_fire = NounPhrase(lex.getWord("fire", "NOUN"), determiner=lex.getWord("the"))
     self.pp_by_the_fire = PrepositionalPhrase(lex.getWord("by", "PREPOSITION"), [self.np_the_fire])
     
     self.np_a_young_girl_with_red_hair_and_glasses = NounPhrase.from_nounphrase(self.np_a_young_girl, prepositional_phrases = [self.pp_with_red_hair_and_glasses])
     
     self.vp_is_sitting = VerbPhrase(lex.getWord("sit"), tense="present_progressive")
     
     self.vp_is_sitting_by_the_fire = VerbPhrase(lex.getWord("sit"), tense="present_progressive", prepositional_phrases = [self.pp_by_the_fire])
     
     self.np_a_young_girl_with_red_hair_and_glasses_is_sitting  = Clause(self.np_a_young_girl_with_red_hair_and_glasses, self.vp_is_sitting)
     
     
     self.np_a_young_girl_with_red_hair_and_glasses_is_sitting_by_the_fire  = Clause(self.np_a_young_girl_with_red_hair_and_glasses, self.vp_is_sitting_by_the_fire) 
예제 #10
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")
예제 #11
0
    def setUp(self):
        #A young girl with red hair and green eyes is sitting in one of three chairs by the fireplace in the northern part of this room.

        lex_path = os.path.join(os.path.dirname(__file__),
                                '../../res/default-lexicon.xml')
        lex = XMLLexicon(lex_path)
        self.lex = lex

        self.np_a_young_girl = NounPhrase(lex.getWord("girl"),
                                          determiner=lex.getWord("a"),
                                          adjectives=[lex.getWord("young")])
        self.np_red_hair = NounPhrase(
            lex.getWord("hair"), adjectives=[lex.getWord("red", "ADJECTIVE")])
        self.np_glasses = NounPhrase(lex.getWord("glasses"))

        self.pp_with_red_hair_and_glasses = PrepositionalPhrase(
            lex.getWord("with"), [self.np_red_hair, self.np_glasses])

        self.np_the_fire = NounPhrase(lex.getWord("fire", "NOUN"),
                                      determiner=lex.getWord("the"))
        self.pp_by_the_fire = PrepositionalPhrase(
            lex.getWord("by", "PREPOSITION"), [self.np_the_fire])

        self.np_a_young_girl_with_red_hair_and_glasses = NounPhrase.from_nounphrase(
            self.np_a_young_girl,
            prepositional_phrases=[self.pp_with_red_hair_and_glasses])

        self.vp_is_sitting = VerbPhrase(lex.getWord("sit"),
                                        tense="present_progressive")

        self.vp_is_sitting_by_the_fire = VerbPhrase(
            lex.getWord("sit"),
            tense="present_progressive",
            prepositional_phrases=[self.pp_by_the_fire])

        self.np_a_young_girl_with_red_hair_and_glasses_is_sitting = Clause(
            self.np_a_young_girl_with_red_hair_and_glasses, self.vp_is_sitting)

        self.np_a_young_girl_with_red_hair_and_glasses_is_sitting_by_the_fire = Clause(
            self.np_a_young_girl_with_red_hair_and_glasses,
            self.vp_is_sitting_by_the_fire)
예제 #12
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")