test_MLW_grammar.py 1.82 KB
Newer Older
1
2
#!/usr/bin/python3

di68kap's avatar
di68kap committed
3
"""test_MLW_grammar.py - unit tests for the MLW grammar 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Author: Eckhart Arnold <arnold@badw.de>

Copyright 2017 Bavarian Academy of Sciences and Humanities

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
di68kap's avatar
di68kap committed
21
from DHParser import testing
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from DHParser import parsers
# from DHParser.dsl import load_compiler_suite
from MLW_compiler import get_MLW_grammar, get_MLW_transformer


MLW_TEST_CASES_LEMMA_POSITION = {

"lemma": {
    "match": {
        1: "facitergula",
        2: "facitergul|a",
        3: "fasc|itergula"
    },
    "fail": {
di68kap's avatar
di68kap committed
36
        99: "duo vocabula"
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
    }
},

"HauptLemma" : {
    "match": {
        1: "facitergula",
        2: "*fascitergula",
        3: "* fasciterugl|a"
    }
},

"LemmaVarianten": {
    "match": {
        1: """
           fasc-itergula
           fac-iet-ergula
           fac-ist-ergula
           fa-rcu-tergula
           """,
        2: " fasc-itergula",
        3: " fasc-itergula fac-iet-ergula ZUSATZ sim.",
    },
    "fail": {
di68kap's avatar
di68kap committed
60
        99: "* fascitergula"
61
62
63
64
65
66
67
68
    }
}

}


class TestMLWGrammar:
    def test_lemma_position(self):
di68kap's avatar
di68kap committed
69
70
71
        errata = testing.test_grammar(MLW_TEST_CASES_LEMMA_POSITION,
                                      get_MLW_grammar,
                                      get_MLW_transformer)
72
73
        assert not errata, str(errata)

di68kap's avatar
di68kap committed
74
75
76

if __name__ == "__main__":
    testing.runner("", globals())