Ejemplo n.º 1
0
def test_pipes(sents, lang):
    inspectors.logger.setLevel(logging.DEBUG)
    inspector_pipes.logger.setLevel(logging.DEBUG)

    data = {'lang': lang, "sents": sents}
    ctx, pat = next(build_context(data, 'verb', name='_test_'))

    rs = pat(pipes(collect=['verb', 'noun']), )
    pprint((rs[1], rs[0], rs[3].results))
    assert all_of(rs)
Ejemplo n.º 2
0
def test_axis():
    from sagas.nlu.rules_lang_spec_hi import axis
    sagas.nlu.inspectors.logger.setLevel(logging.DEBUG)
    sagas.nlu.rules_lang_spec_hi.logger.setLevel(logging.DEBUG)

    data = {'lang': 'hi', "sents": 'मैं सेब खाता हूं'}
    ctx, pat = next(build_context(data, 'verb', name='_test_'))

    all_of = lambda *arg: all([r[1] for r in arg])
    r = all_of(pat(axis('obj').inherit('khadya phala|edible fruits'), ))
    assert r
Ejemplo n.º 3
0
def test_spec_trans_aux():
    from sagas.nlu.parse_client_helper import build_context
    from sagas.nlu.inspector_wordnet import logger

    logger.setLevel(logging.DEBUG)  # only display debug message when fail
    # I’m in a hurry.
    data = {'lang': 'af', "sents": 'Ek is haastig.'}
    ctx, pat = next(build_context(data, 'cop', name='_test_'))

    all_of = lambda *arg: all([r[1] for r in arg])
    r = all_of(pat(specs_trans('*', 'hurriedly').opt(raw_fmt=raw_fmt_pos), ))
    assert r
Ejemplo n.º 4
0
def test_spec_trans():
    from sagas.nlu.parse_client_helper import build_context
    from sagas.nlu.inspector_wordnet import logger

    logger.setLevel(logging.DEBUG)  # only display debug message when fail
    # Please drive slowly.
    data = {'lang': 'af', "sents": 'Ry asseblief stadiger.'}
    ctx, pat = next(build_context(data, 'verb', name='_test_'))

    all_of = lambda *arg: all([r[1] for r in arg])
    r = all_of(
        pat(advmod=specs_trans('*', 'slow', 'fast').opt(raw_fmt=raw_fmt_pos)))
    assert r
    r = all_of(pat(advmod=specs_trans('*', 'slow', 'fast').opt(trans_idx=0)))
    assert r
Ejemplo n.º 5
0
def test_pipes_interr_and_cat(sents, lang):
    from sagas.nlu.pipes import cat
    inspectors.logger.setLevel(logging.DEBUG)
    inspector_pipes.logger.setLevel(logging.DEBUG)
    cat.logger.setLevel(logging.DEBUG)

    data = {'lang': lang, "sents": sents}
    ctx, pat = next(build_context(data, 'cop', name='_test_'))

    rs = pat(
        pipes(interr=pred_cond('/conj/cc', 'but')),
        pipes(pos=pred_cond('/conj', ['adj'])),
        pipes(cat=pred_cond('/conj', 'person')),
    )
    pprint((rs[1], rs[0], rs[3].results))
    assert all_of(rs)
def test_pipes_sense(sents, lang):
    inspectors.logger.setLevel(logging.DEBUG)
    inspector_pipes.logger.setLevel(logging.DEBUG)

    data = {'lang': lang, "sents": sents}
    ctx, pat = next(build_context(data, 'verb', name='_test_'))

    rs = pat(
        pipes(collect=['verb', 'noun']),
        pipes(sense=sense_cond.is_cat('/obl', 'fact|事情').with_roles(
            domain='military|军')),
    )
    pprint((rs[1], rs[0], rs[3].results))
    assert all_of(rs)

    rs = pat(
        pipes(collect=['verb', 'noun']),
        pipes(sense=sense_cond.has_roles('/obl', domain='military|军')),
    )
    pprint((rs[1], rs[0], rs[3].results))
    assert all_of(rs)
Ejemplo n.º 7
0
def test_aux_pos(data, dominator, insp):
    for ctx, serv in build_context(data, dominator, name='_test_'):
        r = serv(**insp)
        assert r[1]
Ejemplo n.º 8
0
def test_behaveof(data, dominator, insp):
    for ctx, serv in build_context(data, dominator, name='_test_'):
        r = serv(insp)
        assert r[1]
Ejemplo n.º 9
0
def test_clauses(data, insp):
    for ctx, _ in build_context(data, 'verb', name='_test_'):
        assert insp.run('', ctx)