aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2020-02-20 21:53:55 +0200
committerGitHub <noreply@github.com>2020-02-20 16:53:55 -0300
commit3c45cf8494fcd29e1a99b0ee6f253808eb607053 (patch)
treecd0e6347bcd2bfc42c18408169a8757ca1dda920 /vendor/github.com
parentefbd7ca39bde69ff84d4b309bee99edfe2977521 (diff)
downloadgitea-3c45cf8494fcd29e1a99b0ee6f253808eb607053.tar.gz
gitea-3c45cf8494fcd29e1a99b0ee6f253808eb607053.zip
Add detected file language to code search (#10256)
Move langauge detection to separate module to be more reusable Add option to disable vendored file exclusion from file search Allways show all language stats for search
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/blevesearch/bleve/analysis/analyzer/keyword/keyword.go38
-rw-r--r--vendor/github.com/blevesearch/bleve/analysis/tokenizer/single/single.go49
2 files changed, 87 insertions, 0 deletions
diff --git a/vendor/github.com/blevesearch/bleve/analysis/analyzer/keyword/keyword.go b/vendor/github.com/blevesearch/bleve/analysis/analyzer/keyword/keyword.go
new file mode 100644
index 0000000000..2a6c1aff71
--- /dev/null
+++ b/vendor/github.com/blevesearch/bleve/analysis/analyzer/keyword/keyword.go
@@ -0,0 +1,38 @@
+// Copyright (c) 2014 Couchbase, Inc.
+//
+// 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.
+
+package keyword
+
+import (
+ "github.com/blevesearch/bleve/analysis"
+ "github.com/blevesearch/bleve/analysis/tokenizer/single"
+ "github.com/blevesearch/bleve/registry"
+)
+
+const Name = "keyword"
+
+func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (*analysis.Analyzer, error) {
+ keywordTokenizer, err := cache.TokenizerNamed(single.Name)
+ if err != nil {
+ return nil, err
+ }
+ rv := analysis.Analyzer{
+ Tokenizer: keywordTokenizer,
+ }
+ return &rv, nil
+}
+
+func init() {
+ registry.RegisterAnalyzer(Name, AnalyzerConstructor)
+}
diff --git a/vendor/github.com/blevesearch/bleve/analysis/tokenizer/single/single.go b/vendor/github.com/blevesearch/bleve/analysis/tokenizer/single/single.go
new file mode 100644
index 0000000000..18b2b1af9b
--- /dev/null
+++ b/vendor/github.com/blevesearch/bleve/analysis/tokenizer/single/single.go
@@ -0,0 +1,49 @@
+// Copyright (c) 2014 Couchbase, Inc.
+//
+// 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.
+
+package single
+
+import (
+ "github.com/blevesearch/bleve/analysis"
+ "github.com/blevesearch/bleve/registry"
+)
+
+const Name = "single"
+
+type SingleTokenTokenizer struct {
+}
+
+func NewSingleTokenTokenizer() *SingleTokenTokenizer {
+ return &SingleTokenTokenizer{}
+}
+
+func (t *SingleTokenTokenizer) Tokenize(input []byte) analysis.TokenStream {
+ return analysis.TokenStream{
+ &analysis.Token{
+ Term: input,
+ Position: 1,
+ Start: 0,
+ End: len(input),
+ Type: analysis.AlphaNumeric,
+ },
+ }
+}
+
+func SingleTokenTokenizerConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.Tokenizer, error) {
+ return NewSingleTokenTokenizer(), nil
+}
+
+func init() {
+ registry.RegisterTokenizer(Name, SingleTokenTokenizerConstructor)
+}