cld -> tinyld

This commit is contained in:
ThatOneCalculator 2023-09-19 17:11:37 -07:00
parent 71e88af1a0
commit 5964a10571
No known key found for this signature in database
GPG Key ID: 8703CACD01000000
4 changed files with 20 additions and 20 deletions

View File

@ -54,7 +54,6 @@
"chalk": "5.3.0",
"chalk-template": "0.4.0",
"chokidar": "^3.5.3",
"cld": "^2.9.0",
"cli-highlight": "2.1.11",
"color-convert": "2.0.1",
"content-disposition": "0.5.4",
@ -133,6 +132,7 @@
"tar-stream": "^3.1.6",
"tesseract.js": "^4.1.1",
"tinycolor2": "1.6.0",
"tinyld": "^1.3.4",
"tmp": "0.2.1",
"twemoji-parser": "14.0.0",
"typeorm": "0.3.17",

View File

@ -23,19 +23,3 @@ interface DetectLanguage {
readonly languages: Language[];
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>;
}

View File

@ -27,7 +27,7 @@ import {
} from "@/misc/populate-emojis.js";
import { db } from "@/db/postgre.js";
import { IdentifiableError } from "@/misc/identifiable-error.js";
import cld from "cld";
import { detect as detectLanguage_ } from "tinyld";
import { detect } from "langdetect";
export async function populatePoll(note: Note, meId: User["id"] | null) {
@ -206,7 +206,7 @@ export const NoteRepository = db.getRepository(Note).extend({
let lang;
try {
lang = (await cld.detect((note.text || "") + (note.cw || "")))
lang = (detectLanguage_((note.text || "") + (note.cw || "")))
.languages[0].code;
} catch (e) {
lang =

View File

@ -279,6 +279,9 @@ importers:
koa-views:
specifier: 7.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:
specifier: workspace:*
version: link:../megalodon
@ -411,6 +414,9 @@ importers:
tinycolor2:
specifier: 1.6.0
version: 1.6.0
tinyld:
specifier: ^1.3.4
version: 1.3.4
tmp:
specifier: 0.2.1
version: 0.2.1
@ -12965,6 +12971,12 @@ packages:
engines: {node: '>=14.16'}
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:
resolution: {integrity: sha512-U/VxvpX4N/rFvPzr3qG5EtLKEnNI0emvIQB3/ecEwv+8GHaUKbIB8vxv1Oai5FAF0d0r7LXHhLLe5K/yChm5GQ==}
engines: {node: '>= 0.10'}
@ -17384,7 +17396,6 @@ packages:
resolution: {integrity: sha512-u26CNoaInA4XpDU+8s/6Cq8xHc2T5M4fXB3ICfXPokUQoLzmPgSZU02TAkFwFMJCWTjk53gtkS8pETTreZwCqw==}
engines: {node: '>= 12.10.0', npm: '>= 6.12.0', yarn: '>= 1.20.0'}
hasBin: true
dev: true
/titleize@3.0.0:
resolution: {integrity: sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==}
@ -18032,6 +18043,11 @@ packages:
busboy: 1.6.0
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:
resolution: {integrity: sha512-lVNOwh2AnmbwqtSrEVjAWKQoVzWgyWmXVqPuPkPfKb0tnA0+uYN/4ILCTdy9IRj/+3drAVhmjwjNJQr2dhCwnA==}
dev: true