1
// Copyright (c) 2014 Couchbase, Inc.
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
21
"github.com/blevesearch/bleve/analysis"
22
"github.com/blevesearch/bleve/registry"
25
func TestEnglishAnalyzer(t *testing.T) {
28
output analysis.TokenStream
32
input: []byte("books"),
33
output: analysis.TokenStream{
43
input: []byte("book"),
44
output: analysis.TokenStream{
56
output: analysis.TokenStream{},
60
input: []byte("steven's"),
61
output: analysis.TokenStream{
63
Term: []byte("steven"),
71
input: []byte("steven\u2019s"),
72
output: analysis.TokenStream{
74
Term: []byte("steven"),
82
input: []byte("steven\uFF07s"),
83
output: analysis.TokenStream{
85
Term: []byte("steven"),
94
cache := registry.NewCache()
95
analyzer, err := cache.AnalyzerNamed(AnalyzerName)
99
for _, test := range tests {
100
actual := analyzer.Analyze(test.input)
101
if !reflect.DeepEqual(actual, test.output) {
102
t.Errorf("expected %v, got %v", test.output, actual)