Пример #1
0
def test_samjna():
    cases = [(
        ['anga'],
        'nara grAma vIra',
        'nara grAma vIra',
    )]

    for pattern, yes, no in cases:
        f = F.samjna(*pattern)
        for y in yes.split():
            assert f.allows([Upadesha.as_anga(y)], 0)
        for n in no.split():
            assert not f.allows([Pratyaya(n)], 0)
Пример #2
0
def test_samjna():
    cases = [
        (['anga'],
            'nara grAma vIra',
            'nara grAma vIra',
        )
    ]

    for pattern, yes, no in cases:
        f = F.samjna(*pattern)
        for y in yes.split():
            assert f.allows([Upadesha.as_anga(y)], 0)
        for n in no.split():
            assert not f.allows([Pratyaya(n)], 0)
Пример #3
0
def verb_data(filename, la):
    """Generate verb data as part of a parametrized test.

    Each datum in the returned list is a 2-tuple containing a single
    form and the result set in which it is expected to appear.

    :param filename: the name of some test file.
    :param la: the upadeśa name of one of the lakāras.
    """
    test_cases = []
    ash = A.Ashtadhyayi()
    for dhatu, expected, person, number in load_forms(filename):
        d = Upadesha.as_dhatu(dhatu)
        p = Vibhakti(la).add_samjna(person, number)
        actual = set(ash.derive([d, p]))
        print actual

        test_cases.append((expected, actual))

    return test_cases
Пример #4
0
def verb_data(filename, la):
    """Generate verb data as part of a parametrized test.

    Each datum in the returned list is a 2-tuple containing a single
    form and the result set in which it is expected to appear.

    :param filename: the name of some test file.
    :param la: the upadeśa name of one of the lakāras.
    """
    test_cases = []
    ash = A.Ashtadhyayi()
    for dhatu, expected, person, number in load_forms(filename):
        d = Upadesha.as_dhatu(dhatu)
        p = Vibhakti(la).add_samjna(person, number)
        actual = set(ash.derive([d, p]))
        print(actual)

        test_cases.append((expected, actual))

    return test_cases
Пример #5
0
def verify(cases, operator):
    for original, expected in cases:
        term = Upadesha('a~').set_value(original)
        state = State([term])
        assert operator.apply(state, 0)[0].value == expected
Пример #6
0
def test_derive(ashtadhyayi):
    dhatu = Upadesha.as_dhatu('BU')
    la = Vibhakti('la~w').add_samjna('prathama', 'ekavacana')
    items = [dhatu, la]
    assert 'Bavati' in ashtadhyayi.derive(items)
Пример #7
0
def dhatu_tester(filt, data):
    return filt.allows([Upadesha.as_dhatu(data)], 0)
Пример #8
0
def term_tester(filt, data):
    term = Upadesha('a~').set_value(data)
    return filt.allows([term], 0)
Пример #9
0
def dhatu_tester(filt, data):
    return filt.allows([Upadesha.as_dhatu(data)], 0)