Exemplo n.º 1
0
 def testPetCustomer(self):
     IPack = InformationPackage()
     IPack.state = Lexicon.Internals.PetCustomer
     IPack.origin = ["Bochum"]
     IPack.destination = ["München"]
     answer = self.AF.createAnswer(IPack).mainAnswer
     self.assertTrue("15.5 Kilogramm" in answer)
Exemplo n.º 2
0
 def testFlexibleStartPoint(self):
     IPack = InformationPackage()
     IPack.state = Lexicon.Internals.FlexibleStartPoint
     IPack.origin = ["Bochum"]
     IPack.destination = ["Bremen"]
     answer = self.AF.createAnswer(IPack).mainAnswer
     self.assertTrue("7 Städte" in answer)
Exemplo n.º 3
0
    def testFindCitys(self):
        IPack = InformationPackage()
        city = ["Bochum"]
        msgs = [
            "Ich wohne in Bochum", "bochum", "Bochum oder so",
            "Bochum wäre klasse, also finde ich jedenfalls. Was meinst du denn Hasi"
        ]  # long inputs
        for msg in msgs:
            IPack.state = Lexicon.Internals.Origin
            self.assertTrue(self.Ana.analyze(msg, IPack).origin == city)

        state = Lexicon.Internals.Y_N_Origin
        msgs = [
            "Also ich fände ja Brochum als Startpunkt gut", "Mühnchen",
            "Ich denke, Bochumr"
        ]
        for msg in msgs:
            IPack.state = Lexicon.Internals.Origin
            self.assertTrue(self.Ana.analyze(msg, IPack).state == state)

        state = Lexicon.Internals.OriginCorrection
        msgs = ["Mühnchänl wär supi", "was willst du denn von mir??"]
        for msg in msgs:
            IPack.state = Lexicon.Internals.Origin
            self.assertTrue(self.Ana.analyze(msg, IPack).state == state)
Exemplo n.º 4
0
 def testExpandDate(self):
     IPack = InformationPackage()
     IPack.setDate([[31, 8, 2023]])
     IPack.state = Lexicon.Internals.FlexibleDate
     self.assertTrue(self.Ana.analyze("ja", IPack).date == [[30, 8, 2023],
                                                            [31, 8, 2023],
                                                            [1, 9, 2023]],
                     msg="expanding_date not working")
Exemplo n.º 5
0
 def test_bug(self):
     IPack = InformationPackage()
     state = Lexicon.Internals.Open
     IPack.setState(state)
     msg = "Anzahl Umstiege"
     self.assertTrue(
         self.Ana.analyze(msg, IPack).state == Lexicon.Internals.Transfers)
     msg = "Anzahl Reisende"
     self.assertTrue(
         self.Ana.analyze(msg, IPack).state == Lexicon.Internals.Traveller)
Exemplo n.º 6
0
 def testYesAndNo(self):
     IPack = InformationPackage()
     # Yes
     state = Lexicon.Internals.StartTutorial
     msgs = ["ja", "japp", "gern", "klar"]
     for msg in msgs:
         IPack.state = Lexicon.Internals.Y_N_Tutorial
         self.assertTrue(self.Ana.analyze(msg, IPack).state == state)
     # No
     state = Lexicon.Internals.Origin
     msgs = ["nein", "nee", "nö", "nope"]
     for msg in msgs:
         IPack.state = Lexicon.Internals.Y_N_Tutorial
         self.assertTrue(self.Ana.analyze(msg, IPack).state == state)
Exemplo n.º 7
0
    def testRequest(self):
        ipack = InformationPackage()
        ipack.setOrigin("Bochum")
        ipack.setDestination("Dortmund")
        ipack.setDate([[22, 8, 2020]])

        man = RequestManager()
        man.setFromIpack(ipack)

        res = man.makeRequest()
        self.assertTrue("origin" in res)
Exemplo n.º 8
0
 def testOpen3(self):
     IPack = InformationPackage()
     IPack.state = Lexicon.Internals.Open
     IPack.traveller = -1
     IPack.budget = 200
     IPack.time = []
     IPack.transfers = -1
     answer = self.AF.createAnswer(IPack).mainAnswer
     self.assertTrue("kannst du mir jetzt noch sagen" in answer)
Exemplo n.º 9
0
 def testOpenStart(self):
     IPack = InformationPackage()
     IPack.state = Lexicon.Internals.Open
     IPack.traveller = -1
     IPack.budget = -1
     IPack.time = []
     IPack.transfers = -1
     answer = self.AF.createAnswer(IPack).preface
     self.assertTrue("alle Informationen" in answer)
Exemplo n.º 10
0
    def testDate(self):
        IPack = InformationPackage()
        state = Lexicon.Internals.FlexibleDate
        msgs = [
            "03.10.2021", "03 10", "03/10", "03.10", "3 Oktober", "3. Oktober",
            "3.Oktober"
        ]
        for msg in msgs:
            IPack.state = Lexicon.Internals.Date
            self.assertTrue(self.Ana.analyze(msg,
                                             IPack).date == [[3, 10, 2021]],
                            msg=f"Message: {msg}")
        msgs = ["morgen", "übermorgen", "10.02"]
        for msg in msgs:
            IPack.state = Lexicon.Internals.Date
            self.assertTrue(self.Ana.analyze(msg, IPack).state == state,
                            msg=f"Message: {msg}")
        msgs = ["31.10.2007", "12.11.2015", "10.02.2020"]
        state = Lexicon.Internals.PastDate
        for msg in msgs:
            IPack.state = Lexicon.Internals.Date
            self.assertTrue(self.Ana.analyze(msg, IPack).state == state,
                            msg=f"Message: {msg}")

        msgs = ["test", "was willst du?"]
        for msg in msgs:
            IPack.state = Lexicon.Internals.Date
            self.assertTrue(self.Ana.analyze(msg, IPack).repeat,
                            msg=f"Message: {msg}")
Exemplo n.º 11
0
 def testTime(self):
     IPack = InformationPackage()
     msgs = [
         "7.30", "7:30", "irgendwann mittags", "abends wäre gut, eher spät"
     ]
     state = Lexicon.Internals.Open
     for msg in msgs:
         IPack.state = Lexicon.Internals.Time
         self.assertTrue(self.Ana.analyze(msg, IPack).state == state)
     IPack.state = Lexicon.Internals.Time
     self.assertTrue(self.Ana.analyze("halb 9", IPack).time == [8, 30])
     IPack.state = Lexicon.Internals.Time
     self.assertTrue(
         self.Ana.analyze("viertel nach neun", IPack).time == [9, 15])
     IPack.state = Lexicon.Internals.Time
     self.assertTrue(
         self.Ana.analyze("viertel vor 9", IPack).time == [8, 45])
     IPack.state = Lexicon.Internals.Time
     self.assertTrue(
         self.Ana.analyze("19 Uhr dreißig", IPack).time == [19, 30])
     IPack.state = Lexicon.Internals.Time
     self.assertTrue(
         self.Ana.analyze("halb 8 abends", IPack).time == [19, 30])
Exemplo n.º 12
0
 def convertJSONToIPack(self, jsondic):
     ip = IPack()
     ip.setFromJSON(jsondic["informationPackage"])
     return ip
Exemplo n.º 13
0
 def testGreeting(self):
     IPack = InformationPackage()
     IPack.state = Lexicon.Internals.Y_N_Tutorial
     ap_msg = Lexicon.Output.ExplGreetings[0]
     self.assertTrue(ap_msg in self.AF.createAnswer(IPack).mainAnswer)
Exemplo n.º 14
0
 def testMoreInformationsToChatbots(self):
     IPack = InformationPackage()
     IPack.state = Lexicon.Internals.GiveMoreInformationsToChatbots
     ap_msg = Lexicon.Output.WikiToChatbots[0]
     self.assertTrue(ap_msg in self.AF.createAnswer(IPack).last)
Exemplo n.º 15
0
 def setFromDict(self, infos):
     if isinstance(infos, dict):
         ipack = IPack()
         ipack.setFromJSON(infos)
         self.setFromIpack(ipack)
Exemplo n.º 16
0
 def testRepeat(self):
     IPack = InformationPackage()
     IPack.state = Lexicon.Internals.StartTutorial
     msg = "hrungendunz"
     self.assertTrue(self.Ana.analyze(msg, IPack).repeat)
Exemplo n.º 17
0
 def testAskForOrigin(self):
     IPack = InformationPackage()
     IPack.state = Lexicon.Internals.Origin
     ap_msgs = Lexicon.Output.AskForOrigin
     self.assertTrue(self.AF.createAnswer(IPack).mainAnswer in ap_msgs)
Exemplo n.º 18
0
def testRequest():
    ipack = InformationPackage()
    ipack.setOrigin("Oberhausen")
    ipack.setDestination("München")
    ipack.setDate([[9, 8, 2020]])
    ipack.setTraveller(1)
    ipack.setTime([])
    ipack.setBudget(-1)
    ipack.setTransfers(-1)

    man = RequestManager()
    man.setFromIpack(ipack)

    res = man.makeRequest()
    print(res)
Exemplo n.º 19
0
 def testGreeting(self):
     IPack = InformationPackage()
     msg = Lexicon.Internals.StartChat
     state = Lexicon.Internals.Y_N_Tutorial
     self.assertTrue(self.Ana.analyze(msg, IPack).state == state)
Exemplo n.º 20
0
 def testBasicType(self):
     IPack = InformationPackage()
     msg = "Test."
     self.assertEqual(type(self.Ana.analyze(msg, IPack)),
                      InformationPackage)
Exemplo n.º 21
0
    def testOpen(self):
        IPack = InformationPackage()
        IPack.traveller = -1
        IPack.budget = -1
        IPack.time = []
        IPack.transfers = -1

        msgs = [
            "Ich würde gerne wenig Geld ausgeben", "hab ein begrentes Budget",
            "bin knapp bei Kasse"
        ]
        state = Lexicon.Internals.Budget
        for msg in msgs:
            IPack.state = Lexicon.Internals.Open
            self.assertTrue(self.Ana.analyze(msg, IPack).state == state)

        msgs = [
            "ich würde gerne mehrere plätze buchen", "wir sind viele",
            "würde gerne mit mehr leuten fahren"
        ]
        state = Lexicon.Internals.Traveller
        for msg in msgs:
            IPack.state = Lexicon.Internals.Open
            self.assertTrue(self.Ana.analyze(msg, IPack).state == state)

        msgs = [
            "ich würde gerne früh los", "will zu einer bestimmten uhrzeit los",
            "abfahrtstermin einstellen"
        ]
        state = Lexicon.Internals.Time
        for msg in msgs:
            IPack.state = Lexicon.Internals.Open
            self.assertTrue(self.Ana.analyze(msg, IPack).state == state,
                            msg=f"{msg}")

        msgs = [
            "ich würde gerne nicht so oft umsteigen",
            "meine toleranz ist gering wegen halten",
            "viele stopps und ich raste aus!"
        ]
        state = Lexicon.Internals.Transfers
        for msg in msgs:
            IPack.state = Lexicon.Internals.Open
            self.assertTrue(self.Ana.analyze(msg, IPack).state == state)

        msgs = [
            "kannst anfangen zu suchen", "starte bitte", "zeig verbindungen"
        ]
        state = Lexicon.Internals.Query
        for msg in msgs:
            IPack.state = Lexicon.Internals.Open
            self.assertTrue(self.Ana.analyze(msg, IPack).state == state)
Exemplo n.º 22
0
 def testTutorial(self):
     IPack = InformationPackage()
     IPack.state = Lexicon.Internals.StartTutorial
     ap_msg = Lexicon.Output.TutorialMsg[0]
     self.assertTrue(ap_msg in self.AF.createAnswer(IPack).mainAnswer)