-
Notifications
You must be signed in to change notification settings - Fork 2
/
morph_test.go
84 lines (78 loc) · 2.03 KB
/
morph_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package opencorpora
import (
"bytes"
"testing"
"github.com/stretchr/testify/require"
)
const dict = `
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<dictionary version="0.92" revision="394634">
<grammemes>
<grammeme parent="">
<name>POST</name>
<alias>ЧР</alias>
<description>часть речи</description>
</grammeme>
<grammeme parent="POST">
<name>NOUN</name>
<alias>СУЩ</alias>
<description>имя существительное</description>
</grammeme>
<grammeme parent="ANim">
<name>anim</name>
<alias>од</alias>
<description>одушевлённое</description>
</grammeme>
<grammeme parent="NMbr">
<name>sing</name>
<alias>ед</alias>
<description>единственное число</description>
</grammeme>
<grammeme parent="CAse">
<name>nomn</name>
<alias>им</alias>
<description>именительный падеж</description>
</grammeme>
<grammeme parent="CAse">
<name>gent</name>
<alias>рд</alias>
<description>родительный падеж</description>
</grammeme>
<grammeme parent="ms-f">
<name>masc</name>
<alias>мр</alias>
<description>мужской род</description>
</grammeme>
</grammemes>
<lemmata>
<lemma id="1" rev="1">
<l t="ёж">
<g v="NOUN"/>
<g v="anim"/>
<g v="masc"/>
</l>
<f t="ёж">
<g v="sing"/>
<g v="nomn"/>
</f>
<f t="ежа">
<g v="sing"/>
<g v="gent"/>
</f>
</lemma>
</lemmata>
</dictionary>
`
func TestMorth(t *testing.T) {
d := &MorphData{}
buf := bytes.NewBufferString(dict)
err := d.ImportFromReader(buf)
require.NoError(t, err)
m := NewMorph()
err = m.readMorphData(d)
require.NoError(t, err)
tag, err := m.Tag("ежа")
require.NoError(t, err)
require.Len(t, tag[0], 5)
require.Equal(t, "NOUN", tag[0][0].Name)
}