Beispiel #1
0
    def answer_human_born_when(c, ts, te):

        def act(c, args):
            human, bd = args
            c.kernal.mem_push(c.user, 'f1ent', human)
            c.kernal.mem_push(c.user, 'f1time', bd)

        import base
        import dateutil.parser

        if ts>=0:
            hss = c.ner(c.lang, 'human', ts, te)
        else:
            hss = c.kernal.mem_get_multi(c.user, 'f1ent')

        for human, score in hss:
            hlabel = c.kernal.prolog_query_one('rdfsLabel(%s, %s, L).' % (human, c.lang))
            # import pdb; pdb.set_trace()
            bd = c.kernal.prolog_query_one('wdpdDateOfBirth(%s, BD).'% human)
            if hlabel and bd:
                bdlabel = base.transcribe_date(dateutil.parser.parse(bd.value), c.lang, 'dativ')
                if c.lang == 'en':
                    c.resp(u"%s was born on %s, I think." % (hlabel, bdlabel), score=score, action=act, action_arg=(human, bd)) 
                    c.resp(u"I believe %s was born on %s." % (hlabel, bdlabel), score=score, action=act, action_arg=(human, bd))
                elif c.lang == 'de':
                    c.resp(u"%s ist am %s geboren, denke ich." % (hlabel, bdlabel), score=score, action=act, action_arg=(human, bd)) 
                    c.resp(u"Ich glaube %s ist am %s geboren." % (hlabel, bdlabel), score=score, action=act, action_arg=(human, bd))
                else:
                    raise Exception ('Sorry, language %s not implemented yet.' % c.lang)
Beispiel #2
0
    def my_birthdate(c):
        def act(c, bd):
            c.kernal.mem_push(c.user, 'f1ent', 'self')
            c.kernal.mem_push(c.user, 'f1time', bd)

        import base
        import dateutil.parser

        for res in c.kernal.prolog_query("wdpdDateOfBirth(self, BD)."):

            bd = res[0]
            bdlabel = base.transcribe_date(dateutil.parser.parse(bd.value),
                                           c.lang, 'dativ')

            if c.lang == 'de':
                c.resp('Ich ging am %s zum ersten Mal in Betrieb.' % bdlabel,
                       score=100.0,
                       action=act,
                       action_arg=bd)
            else:
                c.resp('I became operational on %s for the first time.' %
                       bdlabel,
                       score=100.0,
                       action=act,
                       action_arg=bd)
Beispiel #3
0
    def answer_human_born_when(c, ts, te):

        def act(c, args):
            human, bd = args
            c.kernal.mem_push(c.user, 'f1ent', human)
            c.kernal.mem_push(c.user, 'f1time', bd)

        import base
        import dateutil.parser

        if ts>=0:
            hss = c.ner(c.lang, 'human', ts, te)
        else:
            hss = c.kernal.mem_get_multi(c.user, 'f1ent')

        for human, score in hss:
            hlabel = c.kernal.prolog_query_one('rdfsLabel(%s, %s, L).' % (human, c.lang))
            # import pdb; pdb.set_trace()
            bd = c.kernal.prolog_query_one('wdpdDateOfBirth(%s, BD).'% human)
            if hlabel and bd:
                bdlabel = base.transcribe_date(dateutil.parser.parse(bd), c.lang, 'dativ')
                if c.lang == 'en':
                    c.resp(u"%s was born on %s, I think." % (hlabel, bdlabel), score=score, action=act, action_arg=(human, bd)) 
                    c.resp(u"I believe %s was born on %s." % (hlabel, bdlabel), score=score, action=act, action_arg=(human, bd))
                elif c.lang == 'de':
                    c.resp(u"%s ist am %s geboren, denke ich." % (hlabel, bdlabel), score=score, action=act, action_arg=(human, bd)) 
                    c.resp(u"Ich glaube %s ist am %s geboren." % (hlabel, bdlabel), score=score, action=act, action_arg=(human, bd))
                else:
                    raise Exception ('Sorry, language %s not implemented yet.' % c.lang)
Beispiel #4
0
    def answer_date(c):

        import base

        def set_ent(c):
            c.kernal.mem_push(c.user, 'f1ent', 'wdeCalendarDate')

        ts  = base.transcribe_date(c.current_dt, c.lang, 'dativ') 
        wds = base.transcribe_wday_ts(c.current_dt, c.lang)

        if c.lang == 'en':
            c.resp(u"The date is %s, %s." % (wds, ts), score=100.0, action=set_ent)
            c.resp(u"Today is %s, %s" % (wds, ts), score=100.0, action=set_ent)
        else:
            c.resp(u"Wir haben %s den %s." % (wds, ts), score=100.0, action=set_ent)
            c.resp(u"Heute ist %s den %s." % (wds, ts), score=100.0, action=set_ent)
Beispiel #5
0
    def answer_date(c):

        import base

        def set_ent(c):
            c.kernal.mem_push(c.user, 'f1ent', 'wdeCalendarDate')

        ts  = base.transcribe_date(c.current_dt, c.lang, 'dativ') 
        wds = base.transcribe_wday_ts(c.current_dt, c.lang)

        if c.lang == 'en':
            c.resp(u"The date is %s, %s." % (wds, ts), score=100.0, action=set_ent)
            c.resp(u"Today is %s, %s" % (wds, ts), score=100.0, action=set_ent)
        else:
            c.resp(u"Wir haben %s den %s." % (wds, ts), score=100.0, action=set_ent)
            c.resp(u"Heute ist %s den %s." % (wds, ts), score=100.0, action=set_ent)
Beispiel #6
0
    def my_birthdate(c):

        def act(c, bd):
            c.kernal.mem_push(c.user, 'f1ent', 'self')
            c.kernal.mem_push(c.user, 'f1time', bd)

        import base
        import dateutil.parser

        for res in c.kernal.prolog_query("wdpdDateOfBirth(self, BD)."):

            bd = res[0]
            bdlabel = base.transcribe_date(dateutil.parser.parse(bd.value), c.lang, 'dativ')

            if c.lang=='de':
                c.resp('Ich ging am %s zum ersten Mal in Betrieb.' % bdlabel, score=100.0, action=act, action_arg=bd)
            else:
                c.resp('I became operational on %s for the first time.' % bdlabel, score=100.0, action=act, action_arg=bd)