Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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)
Beispiel #7
0
def dhatu_tester(filt, data):
    return filt.allows([Upadesha.as_dhatu(data)], 0)
Beispiel #8
0
def term_tester(filt, data):
    term = Upadesha('a~').set_value(data)
    return filt.allows([term], 0)
Beispiel #9
0
def dhatu_tester(filt, data):
    return filt.allows([Upadesha.as_dhatu(data)], 0)