cld -> tinyld
This commit is contained in:
parent
71e88af1a0
commit
5964a10571
4 changed files with 20 additions and 20 deletions
|
@ -54,7 +54,6 @@
|
||||||
"chalk": "5.3.0",
|
"chalk": "5.3.0",
|
||||||
"chalk-template": "0.4.0",
|
"chalk-template": "0.4.0",
|
||||||
"chokidar": "^3.5.3",
|
"chokidar": "^3.5.3",
|
||||||
"cld": "^2.9.0",
|
|
||||||
"cli-highlight": "2.1.11",
|
"cli-highlight": "2.1.11",
|
||||||
"color-convert": "2.0.1",
|
"color-convert": "2.0.1",
|
||||||
"content-disposition": "0.5.4",
|
"content-disposition": "0.5.4",
|
||||||
|
@ -133,6 +132,7 @@
|
||||||
"tar-stream": "^3.1.6",
|
"tar-stream": "^3.1.6",
|
||||||
"tesseract.js": "^4.1.1",
|
"tesseract.js": "^4.1.1",
|
||||||
"tinycolor2": "1.6.0",
|
"tinycolor2": "1.6.0",
|
||||||
|
"tinyld": "^1.3.4",
|
||||||
"tmp": "0.2.1",
|
"tmp": "0.2.1",
|
||||||
"twemoji-parser": "14.0.0",
|
"twemoji-parser": "14.0.0",
|
||||||
"typeorm": "0.3.17",
|
"typeorm": "0.3.17",
|
||||||
|
|
16
packages/backend/src/@types/cld.d.ts
vendored
16
packages/backend/src/@types/cld.d.ts
vendored
|
@ -23,19 +23,3 @@ interface DetectLanguage {
|
||||||
readonly languages: Language[];
|
readonly languages: Language[];
|
||||||
readonly chunks: Chunk[];
|
readonly chunks: Chunk[];
|
||||||
}
|
}
|
||||||
export declare module "cld" {
|
|
||||||
declare function detect(
|
|
||||||
text: string,
|
|
||||||
options: Options,
|
|
||||||
callback: (err: string, result: DetectLanguage) => void,
|
|
||||||
): void;
|
|
||||||
declare function detect(
|
|
||||||
text: string,
|
|
||||||
callback: (err: string, result: DetectLanguage) => void,
|
|
||||||
): void;
|
|
||||||
declare function detect(
|
|
||||||
text: string,
|
|
||||||
options: Options,
|
|
||||||
): Promise<DetectLanguage>;
|
|
||||||
declare function detect(text: string): Promise<DetectLanguage>;
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ import {
|
||||||
} from "@/misc/populate-emojis.js";
|
} from "@/misc/populate-emojis.js";
|
||||||
import { db } from "@/db/postgre.js";
|
import { db } from "@/db/postgre.js";
|
||||||
import { IdentifiableError } from "@/misc/identifiable-error.js";
|
import { IdentifiableError } from "@/misc/identifiable-error.js";
|
||||||
import cld from "cld";
|
import { detect as detectLanguage_ } from "tinyld";
|
||||||
import { detect } from "langdetect";
|
import { detect } from "langdetect";
|
||||||
|
|
||||||
export async function populatePoll(note: Note, meId: User["id"] | null) {
|
export async function populatePoll(note: Note, meId: User["id"] | null) {
|
||||||
|
@ -206,7 +206,7 @@ export const NoteRepository = db.getRepository(Note).extend({
|
||||||
|
|
||||||
let lang;
|
let lang;
|
||||||
try {
|
try {
|
||||||
lang = (await cld.detect((note.text || "") + (note.cw || "")))
|
lang = (detectLanguage_((note.text || "") + (note.cw || "")))
|
||||||
.languages[0].code;
|
.languages[0].code;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
lang =
|
lang =
|
||||||
|
|
|
@ -279,6 +279,9 @@ importers:
|
||||||
koa-views:
|
koa-views:
|
||||||
specifier: 7.0.2
|
specifier: 7.0.2
|
||||||
version: 7.0.2(@types/koa@2.13.8)(ejs@3.1.9)(pug@3.0.2)
|
version: 7.0.2(@types/koa@2.13.8)(ejs@3.1.9)(pug@3.0.2)
|
||||||
|
langdetect:
|
||||||
|
specifier: 0.2.1
|
||||||
|
version: 0.2.1
|
||||||
megalodon:
|
megalodon:
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../megalodon
|
version: link:../megalodon
|
||||||
|
@ -411,6 +414,9 @@ importers:
|
||||||
tinycolor2:
|
tinycolor2:
|
||||||
specifier: 1.6.0
|
specifier: 1.6.0
|
||||||
version: 1.6.0
|
version: 1.6.0
|
||||||
|
tinyld:
|
||||||
|
specifier: ^1.3.4
|
||||||
|
version: 1.3.4
|
||||||
tmp:
|
tmp:
|
||||||
specifier: 0.2.1
|
specifier: 0.2.1
|
||||||
version: 0.2.1
|
version: 0.2.1
|
||||||
|
@ -12965,6 +12971,12 @@ packages:
|
||||||
engines: {node: '>=14.16'}
|
engines: {node: '>=14.16'}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/langdetect@0.2.1:
|
||||||
|
resolution: {integrity: sha512-vWK2xz8Urp6J0RFwnrR8+d0DQ2yIGjCOqAxBoXNMVFv4ZDmFsbCcNEtwuVnaQ5+ltwZ4Z5rTtuTwHSaEWFdw+A==}
|
||||||
|
dependencies:
|
||||||
|
unicode-9.0.0: 0.7.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
/last-run@1.1.1:
|
/last-run@1.1.1:
|
||||||
resolution: {integrity: sha512-U/VxvpX4N/rFvPzr3qG5EtLKEnNI0emvIQB3/ecEwv+8GHaUKbIB8vxv1Oai5FAF0d0r7LXHhLLe5K/yChm5GQ==}
|
resolution: {integrity: sha512-U/VxvpX4N/rFvPzr3qG5EtLKEnNI0emvIQB3/ecEwv+8GHaUKbIB8vxv1Oai5FAF0d0r7LXHhLLe5K/yChm5GQ==}
|
||||||
engines: {node: '>= 0.10'}
|
engines: {node: '>= 0.10'}
|
||||||
|
@ -17384,7 +17396,6 @@ packages:
|
||||||
resolution: {integrity: sha512-u26CNoaInA4XpDU+8s/6Cq8xHc2T5M4fXB3ICfXPokUQoLzmPgSZU02TAkFwFMJCWTjk53gtkS8pETTreZwCqw==}
|
resolution: {integrity: sha512-u26CNoaInA4XpDU+8s/6Cq8xHc2T5M4fXB3ICfXPokUQoLzmPgSZU02TAkFwFMJCWTjk53gtkS8pETTreZwCqw==}
|
||||||
engines: {node: '>= 12.10.0', npm: '>= 6.12.0', yarn: '>= 1.20.0'}
|
engines: {node: '>= 12.10.0', npm: '>= 6.12.0', yarn: '>= 1.20.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
|
||||||
|
|
||||||
/titleize@3.0.0:
|
/titleize@3.0.0:
|
||||||
resolution: {integrity: sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==}
|
resolution: {integrity: sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==}
|
||||||
|
@ -18032,6 +18043,11 @@ packages:
|
||||||
busboy: 1.6.0
|
busboy: 1.6.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/unicode-9.0.0@0.7.0:
|
||||||
|
resolution: {integrity: sha512-aqL0GQ3LB2nC3ZEKBZ93hfn7QY80sVGk+OT9Sc6lTxl4wRiwzUBRlAjJB9Fe4+5XydXOV+tb8udp5oRBoED5Tw==}
|
||||||
|
deprecated: Use @unicode/unicode-9.0.0 instead.
|
||||||
|
dev: false
|
||||||
|
|
||||||
/unicode-emoji-json@0.4.0:
|
/unicode-emoji-json@0.4.0:
|
||||||
resolution: {integrity: sha512-lVNOwh2AnmbwqtSrEVjAWKQoVzWgyWmXVqPuPkPfKb0tnA0+uYN/4ILCTdy9IRj/+3drAVhmjwjNJQr2dhCwnA==}
|
resolution: {integrity: sha512-lVNOwh2AnmbwqtSrEVjAWKQoVzWgyWmXVqPuPkPfKb0tnA0+uYN/4ILCTdy9IRj/+3drAVhmjwjNJQr2dhCwnA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
Loading…
Reference in a new issue