Esempio n. 1
0
def extract_nouns(key: Text, ctx: Context, check_fn) -> bool:
    # rs=extract_ko('nouns', ctx.words[key])
    rs = extract_ko('nouns', ctx.get_single_chunk_text(key))
    if rs:
        ctx.add_result('cust', 'nouns', key, rs)
        return True
    return False
Esempio n. 2
0
def extract_datetime(key: Text, ctx: Context, check_fn):
    from sagas.nlu.content_representers import cnt_repr
    rs = cnt_repr.parse_snips(ctx.get_single_chunk_text(key), 'ko')
    if rs:
        ctx.add_result('cust', 'datetime', key, rs)
        return True
    return False
Esempio n. 3
0
def extract_noun_chunk(key: Text, ctx: Context):
    rs = extract_ko('nouns', ctx.get_single_chunk_text(key))
    if rs:
        # return rs[0]['text']
        # 任意一个名词块符合条件即可, 所以用'/'串接
        return '/'.join([w['text'] for w in rs])
    return ctx.words[key]