mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-25 10:45:41 +03:00
Perf over function
This commit is contained in:
parent
d5584f8dd4
commit
f9a73777e7
1 changed files with 5 additions and 0 deletions
|
@ -161,6 +161,11 @@ const SIZE_CLASS = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const detectLang = mem((text) => {
|
const detectLang = mem((text) => {
|
||||||
|
// Ref: https://github.com/komodojp/tinyld/blob/develop/docs/benchmark.md
|
||||||
|
// 500 should be enough for now, also the default max chars for Mastodon
|
||||||
|
if (text?.length > 500) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const langs = detectAll(text);
|
const langs = detectAll(text);
|
||||||
const lang = langs[0];
|
const lang = langs[0];
|
||||||
if (lang?.lang && lang?.accuracy > 0.5) {
|
if (lang?.lang && lang?.accuracy > 0.5) {
|
||||||
|
|
Loading…
Reference in a new issue