rm: remove outdated plugins

This commit is contained in:
kwaroran
2024-06-18 22:06:28 +09:00
parent f4c10b8395
commit be0cd11c26
2 changed files with 0 additions and 103 deletions

View File

@@ -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
}

View File

@@ -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
}