Akron | 8ef408b | 2021-08-02 22:11:04 +0200 | [diff] [blame^] | 1 | package datokenizer |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/stretchr/testify/assert" |
| 8 | ) |
| 9 | |
| 10 | func TestSimpleString(t *testing.T) { |
| 11 | assert := assert.New(t) |
| 12 | |
| 13 | // bau | bauamt |
| 14 | r := strings.NewReader(`##foma-net 1.0## |
| 15 | ##props## |
| 16 | 1 6 7 8 2 2 1 1 1 1 1 2 5B57D486 |
| 17 | ##sigma## |
| 18 | 0 @_EPSILON_SYMBOL_@ |
| 19 | 3 a |
| 20 | 4 b |
| 21 | 5 m |
| 22 | 6 t |
| 23 | 7 u |
| 24 | ##states## |
| 25 | 0 4 1 0 |
| 26 | 1 3 2 0 |
| 27 | 2 7 3 0 |
| 28 | 3 3 4 1 |
| 29 | 4 5 5 0 |
| 30 | 5 6 6 0 |
| 31 | 6 -1 -1 1 |
| 32 | -1 -1 -1 -1 -1 |
| 33 | ##end##`) |
| 34 | |
| 35 | tok := parse(r) // ("tokenizer.fst") |
| 36 | tok.buildDA() |
| 37 | assert.True(tok.match("bau")) |
| 38 | assert.True(tok.match("bauamt")) |
| 39 | assert.False(tok.match("baum")) |
| 40 | } |