示例#1
0
def what_word(turn: DialogTurn):
    word = turn.user_object.get('word')
    if word:
        turn.response_text = f'Вы говорили о слове {word}'
        turn.next_stage = 'word'
    else:
        turn.response_text = 'Вы ещё не искали синонимы'
示例#2
0
def repeat(turn: DialogTurn):
    prev = turn.user_object.get('prev')
    if not prev:
        turn.response_text = 'Не поняла, что повторять'
    else:
        turn.response_text = f"<text>{prev['text']}</text><voice>{prev['voice']}</voice>"
        turn.suggests = prev['suggests']
        turn.next_stage = prev['stage']
示例#3
0
def make_synonym_response(turn: DialogTurn, word=None):
    if not word:
        word = turn.text
    if not word:
        return
    syns = find_synonyms(word)
    all_synonyms = sorted({
        text
        for ss in syns for text in ss
        if word.upper() not in text.upper().split()
    })
    if not all_synonyms:
        turn.response_text = f'Простите, не нашла синонимов к слову "{word}".'
        return
    turn.response_text = f'Синонимы к слову "{word}":'
    for syn in all_synonyms[:-1]:
        turn.response_text += '\n' + syn + ';'
    turn.response_text += '\n' + all_synonyms[-1] + '.'

    turn.user_object['word'] = word
示例#4
0
文件: main.py 项目: avidale/dialogic
def hello(turn: DialogTurn):
    turn.response_text = 'Hello! This is the only conditional phrase I have.'
示例#5
0
文件: main.py 项目: avidale/dialogic
def fallback(turn: DialogTurn):
    turn.response_text = 'Hi! Sorry, I do not understand you.'
    turn.suggests.append('hello')
示例#6
0
 def fallback(turn: DialogTurn):
     turn.response_text = 'hi'
示例#7
0
 def fallback(turn: DialogTurn):
     turn.response_text = 'shalom my friend'
示例#8
0
def t3(turn: DialogTurn):
    turn.response_text = '2'
示例#9
0
def do_help(turn: DialogTurn):
    turn.response_text = 'Привет! Вы в навыке "Синоним к слову". ' \
                         'Скажите любое слово, а я найду синонимы к нему.' \
                         '\nЧтобы выйти, скажите "хватит".'
    turn.suggests.append('выход')
示例#10
0
def hello(turn: DialogTurn):
    turn.response_text = 'Привет! Вы в навыке "Синоним к слову". ' \
                         'Скажите любое слово, а я найду синонимы к нему.'
    turn.suggests.append('выход')
示例#11
0
def t0(turn: DialogTurn):
    turn.response_text = '0'
示例#12
0
def test_postprocess():
    turn = DialogTurn(make_context(text='kek'), text='kek')
    turn.response_text = 'The weather is cool.'
    # without agenda, no postprocessors are called
    turn.release_control()
    csc.postprocess(turn)
    assert turn.response_text.endswith('cool.')
    # without control, no postprocessors are called
    turn.take_control()
    turn.add_agenda('ask_for_tea')
    csc.postprocess(turn)
    assert turn.response_text.endswith('cool.')
    # with control and agenda, postprocessors are called
    turn.release_control()
    csc.postprocess(turn)
    assert turn.response_text.endswith('tea?')
    # after postprocessing, agenda goes away
    assert not turn.agenda
示例#13
0
def test_ranking_stage():
    ctx = Context(message_text='kek', user_object={'stage': 's1'}, metadata=None)
    turn = DialogTurn(ctx, text='kek', intents={'i3': 1})
    assert turn.old_user_object == {'stage': 's1'}
    assert turn.stage == 's1'
    assert csc(turn) == 't4'
示例#14
0
def test_ranking(intents, result):
    turn = DialogTurn(make_context(text='kek'), text='kek', intents=intents)
    assert csc(turn) == result
示例#15
0
def t4(turn: DialogTurn):
    turn.response_text = 'stage 1'
示例#16
0
def total_exit(turn: DialogTurn):
    turn.response_text = 'Было приятно пообщаться! ' \
                         'Чтобы обратиться ко мне снова, ' \
                         'запустите навык "Синоним к слову".'
    turn.commands.append(COMMANDS.EXIT)
示例#17
0
文件: dm.py 项目: lilrdn/pleiades-bot
def try_forms(turn: DialogTurn):
    for dm in form_dms:
        form_response = dm.try_to_respond(turn.ctx)
        if form_response:
            turn.response = form_response
            return
示例#18
0
def t1(turn: DialogTurn):
    turn.response_text = '1'