mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor: code preferences, formatting
This commit is contained in:
parent
36d09af467
commit
9c7e35a6b4
1 changed files with 8 additions and 8 deletions
|
|
@ -9,15 +9,15 @@ linkify.registerCustomProtocol('nostr', true);
|
|||
*/
|
||||
export function detectLanguage(text: string, minConfidence: number): LanguageCode | undefined {
|
||||
// It's better to remove the emojis first
|
||||
const sanitizedText = (linkify.tokenize(
|
||||
text.replaceAll(/\p{Extended_Pictographic}/gu, '')
|
||||
const sanitizedText = linkify.tokenize(
|
||||
text
|
||||
.replaceAll(/\p{Extended_Pictographic}/gu, '')
|
||||
.replaceAll(/[\s\uFEFF\u00A0\u200B-\u200D\u{0FE0E}]+/gu, ' '),
|
||||
)
|
||||
.reduce(
|
||||
(acc, { t, v }) => t === 'text' ? acc + v : acc,
|
||||
'',
|
||||
)).trim();
|
||||
if (sanitizedText.length < 10) return; // heuristics
|
||||
).reduce((acc, { t, v }) => t === 'text' ? acc + v : acc, '').trim();
|
||||
|
||||
if (sanitizedText.length < 10) { // heuristics
|
||||
return;
|
||||
}
|
||||
|
||||
const [topResult] = lande(
|
||||
sanitizedText,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue