mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 22:34:25 +01:00
do not use language detector model on dev mode.
because it's slow.
This commit is contained in:
@@ -115,17 +115,19 @@ type ScriptRange struct {
|
|||||||
|
|
||||||
func initializeImageDrawingStuff() error {
|
func initializeImageDrawingStuff() error {
|
||||||
// language detector
|
// language detector
|
||||||
detector = lingua.NewLanguageDetectorBuilder().FromLanguages(
|
if !s.SkipLanguageModel {
|
||||||
lingua.Japanese,
|
detector = lingua.NewLanguageDetectorBuilder().FromLanguages(
|
||||||
lingua.Persian,
|
lingua.Japanese,
|
||||||
lingua.Chinese,
|
lingua.Persian,
|
||||||
lingua.Thai,
|
lingua.Chinese,
|
||||||
lingua.Hebrew,
|
lingua.Thai,
|
||||||
lingua.Arabic,
|
lingua.Hebrew,
|
||||||
lingua.Bengali,
|
lingua.Arabic,
|
||||||
lingua.Hindi,
|
lingua.Bengali,
|
||||||
lingua.Korean,
|
lingua.Hindi,
|
||||||
).WithLowAccuracyMode().Build()
|
lingua.Korean,
|
||||||
|
).WithLowAccuracyMode().Build()
|
||||||
|
}
|
||||||
|
|
||||||
// script detector material
|
// script detector material
|
||||||
for _, srange := range language.ScriptRanges {
|
for _, srange := range language.ScriptRanges {
|
||||||
@@ -252,11 +254,15 @@ gotScriptIndex:
|
|||||||
direction := directionMap[idx]
|
direction := directionMap[idx]
|
||||||
|
|
||||||
lng := language.Language("en-us")
|
lng := language.Language("en-us")
|
||||||
lang, ok := detector.DetectLanguageOf(string(paragraph))
|
if detector == nil {
|
||||||
if ok {
|
|
||||||
lng = language.Language(lang.IsoCode639_1().String())
|
|
||||||
} else {
|
|
||||||
lng = defaultLanguageMap[idx]
|
lng = defaultLanguageMap[idx]
|
||||||
|
} else {
|
||||||
|
lang, ok := detector.DetectLanguageOf(string(paragraph))
|
||||||
|
if ok {
|
||||||
|
lng = language.Language(lang.IsoCode639_1().String())
|
||||||
|
} else {
|
||||||
|
lng = defaultLanguageMap[idx]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lng, script, direction, face
|
return lng, script, direction, face
|
||||||
|
|||||||
2
justfile
2
justfile
@@ -1,7 +1,7 @@
|
|||||||
export PATH := "./node_modules/.bin:" + env_var('PATH')
|
export PATH := "./node_modules/.bin:" + env_var('PATH')
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
TAILWIND_DEBUG=true go build -o /tmp/njump && /tmp/njump
|
TAILWIND_DEBUG=true SKIP_LANGUAGE_MODEL=true go build -o /tmp/njump && /tmp/njump
|
||||||
|
|
||||||
check-samples:
|
check-samples:
|
||||||
#!/usr/bin/env xonsh
|
#!/usr/bin/env xonsh
|
||||||
|
|||||||
11
main.go
11
main.go
@@ -19,11 +19,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
Port string `envconfig:"PORT" default:"2999"`
|
Port string `envconfig:"PORT" default:"2999"`
|
||||||
Domain string `envconfig:"DOMAIN" default:"njump.me"`
|
Domain string `envconfig:"DOMAIN" default:"njump.me"`
|
||||||
DiskCachePath string `envconfig:"DISK_CACHE_PATH" default:"/tmp/njump-internal"`
|
DiskCachePath string `envconfig:"DISK_CACHE_PATH" default:"/tmp/njump-internal"`
|
||||||
EventStorePath string `envconfig:"EVENT_STORE_PATH" default:"/tmp/njump-db"`
|
EventStorePath string `envconfig:"EVENT_STORE_PATH" default:"/tmp/njump-db"`
|
||||||
TailwindDebug bool `envconfig:"TAILWIND_DEBUG"`
|
TailwindDebug bool `envconfig:"TAILWIND_DEBUG"`
|
||||||
|
SkipLanguageModel bool `envconfig:"SKIP_LANGUAGE_MODEL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:embed static/*
|
//go:embed static/*
|
||||||
|
|||||||
Reference in New Issue
Block a user