From be0cd11c26bad36d1c916395c8286f7d1405fe4e Mon Sep 17 00:00:00 2001 From: kwaroran Date: Tue, 18 Jun 2024 22:06:28 +0900 Subject: [PATCH] rm: remove outdated plugins --- src/ts/plugins/fixer.ts | 54 --------------------------------------- src/ts/plugins/metrica.ts | 49 ----------------------------------- 2 files changed, 103 deletions(-) delete mode 100644 src/ts/plugins/fixer.ts delete mode 100644 src/ts/plugins/metrica.ts diff --git a/src/ts/plugins/fixer.ts b/src/ts/plugins/fixer.ts deleted file mode 100644 index eacf379a..00000000 --- a/src/ts/plugins/fixer.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { get } from "svelte/store" -import { DataBase } from "../storage/database" - -export function OaifixBias(bias:{[key:number]:number}){ - const db = get(DataBase) - const emdashes = [ - 2001, 2345, 8713, 16620, 17223, - 22416, 29096, 29472, 30697, 35192, - 38542, 41128, 44603, 49525, 50004, - 50617, 51749, 51757, 55434, 60654, - 61311, 63750, 63938, 63977, 66101, - 68850, 71201, 71480, 72318, 76070, - 76929, 80078, 81902, 83872, 84941, - 85366, 86319, 87247, 87671, 88958, - 90863, 93830, 96197, 99563 - ] - - const biases = [] - - if(db.officialplugins.oaiFixEmdash){ - biases.push(...emdashes) - } - - - for (const key of biases) { - bias[key] = -100 - } - - return bias - -} - -export function OaiFixKorean(text:string){ - - //tokenizer problem fixes - const replacer = { - //commonly wrong english - '피츠': '피스', - '스커츠': '스커트', - '스파츠': '스커트', - '스마트폰': '스파트폰', - '스위츠': '스위치', - '해도 되': '해도 돼', - '해도 됩니다': '해도 돼요', - '에레베이터': '엘리베이터', - '에리베이터': '엘리베이터', - '에레바토르': '엘리베이터', - } - - for (const key in replacer) { - text = text.replace(key, replacer[key]) - } - return text -} \ No newline at end of file diff --git a/src/ts/plugins/metrica.ts b/src/ts/plugins/metrica.ts deleted file mode 100644 index f930db03..00000000 --- a/src/ts/plugins/metrica.ts +++ /dev/null @@ -1,49 +0,0 @@ -// [from, to, ratio, isMetrica] -const convertion:[string,string,number, boolean][] = [ - ['kg', 'lbs', 2.20462, true], - ['m', 'ft', 3.28084, true], - ['cm', 'inch', 0.393701, false], - ['mm', 'inch', 0.0393701, false], - ['km', 'mi', 0.621371, false], - ['killogram', 'pound', 2.20462, true], - ['meter', 'foot', 3.28084, true], - ['centimeter', 'inch', 0.393701, true], - ['millimeter', 'inch', 0.0393701, true], - ['kilometer', 'mile', 0.621371, true], -] - -export function metricaPlugin(data:string, toSystem:'metrics'|'imperial'){ - const c = convertion.sort((a,b) => b[0].length - a[0].length); - for(let i = 0; i < c.length; i++){ - let [from, to, ratio] = c[i]; - if(toSystem !== 'imperial'){ - [from, to] = [to, from]; - ratio = 1 / ratio; - } - if(!c[i][3]){ - from = from + ' ' - to = to + ' ' - } - const reg = new RegExp(`(\\d+(?:\\.\\d+)?)\\s*${from}`, 'g'); - data = data.replace(reg, (_, value) => { - // if value is integer, parse it as integer - if(value.indexOf('.') === -1){ - const result = parseInt(value) * ratio - return `${result.toFixed(0)} ${to}`; - } - - const result = parseFloat(value) * ratio; - return `${result.toFixed(2)} ${to}`; - }); - } - //convert height like 5' 11'' to 180 cm - if(toSystem === 'metrics'){ - const reg = /(\d+)'\s*(\d+)"/g; - data = data.replace(reg, (_, feet, inch) => { - const result = parseFloat(feet) * 30.48 + parseFloat(inch) * 2.54; - return `${result.toFixed(2)} cm`; - }); - } - - return data -} \ No newline at end of file