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,6 +115,7 @@ type ScriptRange struct {
|
||||
|
||||
func initializeImageDrawingStuff() error {
|
||||
// language detector
|
||||
if !s.SkipLanguageModel {
|
||||
detector = lingua.NewLanguageDetectorBuilder().FromLanguages(
|
||||
lingua.Japanese,
|
||||
lingua.Persian,
|
||||
@@ -126,6 +127,7 @@ func initializeImageDrawingStuff() error {
|
||||
lingua.Hindi,
|
||||
lingua.Korean,
|
||||
).WithLowAccuracyMode().Build()
|
||||
}
|
||||
|
||||
// script detector material
|
||||
for _, srange := range language.ScriptRanges {
|
||||
@@ -252,12 +254,16 @@ gotScriptIndex:
|
||||
direction := directionMap[idx]
|
||||
|
||||
lng := language.Language("en-us")
|
||||
if detector == nil {
|
||||
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
|
||||
}
|
||||
|
||||
2
justfile
2
justfile
@@ -1,7 +1,7 @@
|
||||
export PATH := "./node_modules/.bin:" + env_var('PATH')
|
||||
|
||||
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:
|
||||
#!/usr/bin/env xonsh
|
||||
|
||||
1
main.go
1
main.go
@@ -24,6 +24,7 @@ type Settings struct {
|
||||
DiskCachePath string `envconfig:"DISK_CACHE_PATH" default:"/tmp/njump-internal"`
|
||||
EventStorePath string `envconfig:"EVENT_STORE_PATH" default:"/tmp/njump-db"`
|
||||
TailwindDebug bool `envconfig:"TAILWIND_DEBUG"`
|
||||
SkipLanguageModel bool `envconfig:"SKIP_LANGUAGE_MODEL"`
|
||||
}
|
||||
|
||||
//go:embed static/*
|
||||
|
||||
Reference in New Issue
Block a user