Skip to content

Commit

Permalink
Refactor registry components to return an error instead of panicking …
Browse files Browse the repository at this point in the history
…on duplicate analysis component registration
  • Loading branch information
CascadingRadium committed Feb 25, 2025
1 parent 0ca3253 commit 9fefb18
Show file tree
Hide file tree
Showing 199 changed files with 788 additions and 215 deletions.
5 changes: 4 additions & 1 deletion analysis/analyzer/custom/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterAnalyzer(Name, AnalyzerConstructor)
err := registry.RegisterAnalyzer(Name, AnalyzerConstructor)
if err != nil {
panic(err)
}
}

func getCharFilters(charFilterNames []string, cache *registry.Cache) ([]analysis.CharFilter, error) {
Expand Down
5 changes: 4 additions & 1 deletion analysis/analyzer/keyword/keyword.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterAnalyzer(Name, AnalyzerConstructor)
err := registry.RegisterAnalyzer(Name, AnalyzerConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/analyzer/simple/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterAnalyzer(Name, AnalyzerConstructor)
err := registry.RegisterAnalyzer(Name, AnalyzerConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/analyzer/standard/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterAnalyzer(Name, AnalyzerConstructor)
err := registry.RegisterAnalyzer(Name, AnalyzerConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/analyzer/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterAnalyzer(Name, AnalyzerConstructor)
err := registry.RegisterAnalyzer(Name, AnalyzerConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/char/asciifolding/asciifolding.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ func AsciiFoldingFilterConstructor(config map[string]interface{}, cache *registr
}

func init() {
registry.RegisterCharFilter(Name, AsciiFoldingFilterConstructor)
err := registry.RegisterCharFilter(Name, AsciiFoldingFilterConstructor)
if err != nil {
panic(err)
}
}

// Converts characters above ASCII to their ASCII equivalents.
Expand Down
5 changes: 4 additions & 1 deletion analysis/char/html/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,8 @@ func CharFilterConstructor(config map[string]interface{}, cache *registry.Cache)
}

func init() {
registry.RegisterCharFilter(Name, CharFilterConstructor)
err := registry.RegisterCharFilter(Name, CharFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/char/regexp/regexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@ func CharFilterConstructor(config map[string]interface{}, cache *registry.Cache)
}

func init() {
registry.RegisterCharFilter(Name, CharFilterConstructor)
err := registry.RegisterCharFilter(Name, CharFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/char/zerowidthnonjoiner/zerowidthnonjoiner.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ func CharFilterConstructor(config map[string]interface{}, cache *registry.Cache)
}

func init() {
registry.RegisterCharFilter(Name, CharFilterConstructor)
err := registry.RegisterCharFilter(Name, CharFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/datetime/flexible/flexible.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,8 @@ func DateTimeParserConstructor(config map[string]interface{}, cache *registry.Ca
}

func init() {
registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
err := registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/datetime/iso/iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,8 @@ func DateTimeParserConstructor(config map[string]interface{}, cache *registry.Ca
}

func init() {
registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
err := registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/datetime/optional/optional.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@ func DateTimeParserConstructor(config map[string]interface{}, cache *registry.Ca
}

func init() {
registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
err := registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/datetime/percent/percent.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,8 @@ func DateTimeParserConstructor(config map[string]interface{}, cache *registry.Ca
}

func init() {
registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
err := registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/datetime/sanitized/sanitized.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,8 @@ func DateTimeParserConstructor(config map[string]interface{}, cache *registry.Ca
}

func init() {
registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
err := registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/datetime/timestamp/microseconds/microseconds.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ func DateTimeParserConstructor(config map[string]interface{}, cache *registry.Ca
}

func init() {
registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
err := registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/datetime/timestamp/milliseconds/milliseconds.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ func DateTimeParserConstructor(config map[string]interface{}, cache *registry.Ca
}

func init() {
registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
err := registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/datetime/timestamp/nanoseconds/nanoseconds.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ func DateTimeParserConstructor(config map[string]interface{}, cache *registry.Ca
}

func init() {
registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
err := registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/datetime/timestamp/seconds/seconds.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ func DateTimeParserConstructor(config map[string]interface{}, cache *registry.Ca
}

func init() {
registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
err := registry.RegisterDateTimeParser(Name, DateTimeParserConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ar/analyzer_ar.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,8 @@ func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterAnalyzer(AnalyzerName, AnalyzerConstructor)
err := registry.RegisterAnalyzer(AnalyzerName, AnalyzerConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ar/arabic_normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,8 @@ func NormalizerFilterConstructor(config map[string]interface{}, cache *registry.
}

func init() {
registry.RegisterTokenFilter(NormalizeName, NormalizerFilterConstructor)
err := registry.RegisterTokenFilter(NormalizeName, NormalizerFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ar/stemmer_ar.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,8 @@ func StemmerFilterConstructor(config map[string]interface{}, cache *registry.Cac
}

func init() {
registry.RegisterTokenFilter(StemmerName, StemmerFilterConstructor)
err := registry.RegisterTokenFilter(StemmerName, StemmerFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ar/stop_filter_ar.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.C
}

func init() {
registry.RegisterTokenFilter(StopName, StopTokenFilterConstructor)
err := registry.RegisterTokenFilter(StopName, StopTokenFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ar/stop_words_ar.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,8 @@ func TokenMapConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterTokenMap(StopName, TokenMapConstructor)
err := registry.RegisterTokenMap(StopName, TokenMapConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/bg/stop_filter_bg.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.C
}

func init() {
registry.RegisterTokenFilter(StopName, StopTokenFilterConstructor)
err := registry.RegisterTokenFilter(StopName, StopTokenFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/bg/stop_words_bg.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,8 @@ func TokenMapConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterTokenMap(StopName, TokenMapConstructor)
err := registry.RegisterTokenMap(StopName, TokenMapConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ca/articles_ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ func ArticlesTokenMapConstructor(config map[string]interface{}, cache *registry.
}

func init() {
registry.RegisterTokenMap(ArticlesName, ArticlesTokenMapConstructor)
err := registry.RegisterTokenMap(ArticlesName, ArticlesTokenMapConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ca/elision_ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ func ElisionFilterConstructor(config map[string]interface{}, cache *registry.Cac
}

func init() {
registry.RegisterTokenFilter(ElisionName, ElisionFilterConstructor)
err := registry.RegisterTokenFilter(ElisionName, ElisionFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ca/stop_filter_ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.C
}

func init() {
registry.RegisterTokenFilter(StopName, StopTokenFilterConstructor)
err := registry.RegisterTokenFilter(StopName, StopTokenFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ca/stop_words_ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,8 @@ func TokenMapConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterTokenMap(StopName, TokenMapConstructor)
err := registry.RegisterTokenMap(StopName, TokenMapConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/cjk/analyzer_cjk.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterAnalyzer(AnalyzerName, AnalyzerConstructor)
err := registry.RegisterAnalyzer(AnalyzerName, AnalyzerConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/cjk/cjk_bigram.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,8 @@ func CJKBigramFilterConstructor(config map[string]interface{}, cache *registry.C
}

func init() {
registry.RegisterTokenFilter(BigramName, CJKBigramFilterConstructor)
err := registry.RegisterTokenFilter(BigramName, CJKBigramFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/cjk/cjk_width.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,8 @@ func CJKWidthFilterConstructor(config map[string]interface{}, cache *registry.Ca
}

func init() {
registry.RegisterTokenFilter(WidthName, CJKWidthFilterConstructor)
err := registry.RegisterTokenFilter(WidthName, CJKWidthFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ckb/analyzer_ckb.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@ func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterAnalyzer(AnalyzerName, AnalyzerConstructor)
err := registry.RegisterAnalyzer(AnalyzerName, AnalyzerConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ckb/sorani_normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,8 @@ func NormalizerFilterConstructor(config map[string]interface{}, cache *registry.
}

func init() {
registry.RegisterTokenFilter(NormalizeName, NormalizerFilterConstructor)
err := registry.RegisterTokenFilter(NormalizeName, NormalizerFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ckb/sorani_stemmer_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,8 @@ func StemmerFilterConstructor(config map[string]interface{}, cache *registry.Cac
}

func init() {
registry.RegisterTokenFilter(StemmerName, StemmerFilterConstructor)
err := registry.RegisterTokenFilter(StemmerName, StemmerFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ckb/stop_filter_ckb.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.C
}

func init() {
registry.RegisterTokenFilter(StopName, StopTokenFilterConstructor)
err := registry.RegisterTokenFilter(StopName, StopTokenFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/ckb/stop_words_ckb.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,8 @@ func TokenMapConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterTokenMap(StopName, TokenMapConstructor)
err := registry.RegisterTokenMap(StopName, TokenMapConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/cs/stop_filter_cs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.C
}

func init() {
registry.RegisterTokenFilter(StopName, StopTokenFilterConstructor)
err := registry.RegisterTokenFilter(StopName, StopTokenFilterConstructor)
if err != nil {
panic(err)
}
}
5 changes: 4 additions & 1 deletion analysis/lang/cs/stop_words_cs.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,8 @@ func TokenMapConstructor(config map[string]interface{}, cache *registry.Cache) (
}

func init() {
registry.RegisterTokenMap(StopName, TokenMapConstructor)
err := registry.RegisterTokenMap(StopName, TokenMapConstructor)
if err != nil {
panic(err)
}
}
Loading

0 comments on commit 9fefb18

Please sign in to comment.