38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
export function detectLanguage(text: string): string {
|
||
if (/[\u4e00-\u9fff]/.test(text)) return 'Chinese';
|
||
if (/[\u3040-\u309f\u30a0-\u30ff]/.test(text)) return 'Japanese';
|
||
if (/[\uac00-\ud7af]/.test(text)) return 'Korean';
|
||
if (/[àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ]/.test(text)) return 'Romance Language';
|
||
if (/[а-яё]/.test(text.toLowerCase())) return 'Russian';
|
||
if (/[α-ωΑ-Ω]/.test(text)) return 'Greek';
|
||
if (/[أ-ي]/.test(text)) return 'Arabic';
|
||
if (/[א-ת]/.test(text)) return 'Hebrew';
|
||
return 'English';
|
||
}
|
||
|
||
export function detectEnhancements(originalPrompt: string, enhancedPrompt: string): string[] {
|
||
const enhancements: string[] = [];
|
||
|
||
if (enhancedPrompt.length > originalPrompt.length * 1.5) {
|
||
enhancements.push('Added detailed descriptions');
|
||
}
|
||
|
||
if (
|
||
enhancedPrompt.includes('photorealistic') ||
|
||
enhancedPrompt.includes('shot') ||
|
||
enhancedPrompt.includes('lens')
|
||
) {
|
||
enhancements.push('Applied photography terminology');
|
||
}
|
||
|
||
if (enhancedPrompt.includes('lighting') || enhancedPrompt.includes('illuminated')) {
|
||
enhancements.push('Enhanced lighting description');
|
||
}
|
||
|
||
if (enhancedPrompt.includes('texture') || enhancedPrompt.includes('surface')) {
|
||
enhancements.push('Added texture details');
|
||
}
|
||
|
||
return enhancements;
|
||
}
|