File: porterstemmer_is_consontant_test.go

package info (click to toggle)
golang-github-blevesearch-go-porterstemmer 1.0.1%2Bgit20141230.9.23a2c8e-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 188 kB
  • sloc: makefile: 2
file content (74 lines) | stat: -rw-r--r-- 1,844 bytes parent folder | download | duplicates (3)
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
package porterstemmer

import (
	"testing"
)

func TestIsConsontant(t *testing.T) {

	i := 0

	tests := make([]struct {
		S        []rune
		Expected []bool
	}, 12)

	tests[i].S = []rune("apple")
	tests[i].Expected = []bool{false, true, true, true, false}
	i++

	tests[i].S = []rune("cyan")
	tests[i].Expected = []bool{true, false, false, true}
	i++

	tests[i].S = []rune("connects")
	tests[i].Expected = []bool{true, false, true, true, false, true, true, true}
	i++

	tests[i].S = []rune("yellow")
	tests[i].Expected = []bool{true, false, true, true, false, true}
	i++

	tests[i].S = []rune("excellent")
	tests[i].Expected = []bool{false, true, true, false, true, true, false, true, true}
	i++

	tests[i].S = []rune("yuk")
	tests[i].Expected = []bool{true, false, true}
	i++

	tests[i].S = []rune("syzygy")
	tests[i].Expected = []bool{true, false, true, false, true, false}
	i++

	tests[i].S = []rune("school")
	tests[i].Expected = []bool{true, true, true, false, false, true}
	i++

	tests[i].S = []rune("pay")
	tests[i].Expected = []bool{true, false, true}
	i++

	tests[i].S = []rune("golang")
	tests[i].Expected = []bool{true, false, true, false, true, true}
	i++

	// NOTE: The Porter Stemmer technical should make a mistake on the second "y".
	//       Really, both the 1st and 2nd "y" are consontants. But
	tests[i].S = []rune("sayyid")
	tests[i].Expected = []bool{true, false, true, false, false, true}
	i++

	tests[i].S = []rune("ya")
	tests[i].Expected = []bool{true, false}
	i++

	for _, datum := range tests {
		for i = 0; i < len(datum.S); i++ {

			if actual := isConsonant(datum.S, i); actual != datum.Expected[i] {
				t.Errorf("Did NOT get what was expected for calling isConsonant() on [%s] at [%d] (i.e., [%s]). Expect [%t] but got [%t]", string(datum.S), i, string(datum.S[i]), datum.Expected[i], actual)
			}
		} // for
	}
}