mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-05-23 15:00:41 +08:00
refactor: lint format
This commit is contained in:
@@ -72,12 +72,9 @@ export function registerNlpHandlers(_ctx: IpcContext): void {
|
||||
return isDictDownloaded(dictId)
|
||||
})
|
||||
|
||||
ipcMain.handle(
|
||||
'nlp:downloadDict',
|
||||
async (_event, dictId: string): Promise<{ success: boolean; error?: string }> => {
|
||||
return downloadDict(dictId)
|
||||
}
|
||||
)
|
||||
ipcMain.handle('nlp:downloadDict', async (_event, dictId: string): Promise<{ success: boolean; error?: string }> => {
|
||||
return downloadDict(dictId)
|
||||
})
|
||||
|
||||
ipcMain.handle('nlp:deleteDict', async (_event, dictId: string): Promise<{ success: boolean; error?: string }> => {
|
||||
return deleteDict(dictId)
|
||||
|
||||
@@ -108,13 +108,19 @@ export async function downloadDict(
|
||||
if (buffer.length < MIN_DICT_SIZE) {
|
||||
const preview = buffer.subarray(0, 200).toString('utf-8')
|
||||
console.error(`[NLP DictManager] Downloaded file too small (${buffer.length} bytes), preview: ${preview}`)
|
||||
return { success: false, error: `Downloaded file is invalid (${buffer.length} bytes). The dictionary URL may not be available yet.` }
|
||||
return {
|
||||
success: false,
|
||||
error: `Downloaded file is invalid (${buffer.length} bytes). The dictionary URL may not be available yet.`,
|
||||
}
|
||||
}
|
||||
|
||||
const head = buffer.subarray(0, 50).toString('utf-8').trim()
|
||||
if (head.startsWith('<!') || head.startsWith('<html')) {
|
||||
console.error(`[NLP DictManager] Downloaded file appears to be HTML, not a dict file`)
|
||||
return { success: false, error: 'Downloaded file is HTML, not a dictionary file. The URL may not be deployed yet.' }
|
||||
return {
|
||||
success: false,
|
||||
error: 'Downloaded file is HTML, not a dictionary file. The URL may not be deployed yet.',
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync(tmpPath, buffer)
|
||||
|
||||
@@ -385,7 +385,16 @@ export function batchSegmentWithFrequency(
|
||||
locale: SupportedLocale,
|
||||
options: BatchSegmentOptions = {}
|
||||
): BatchSegmentResult {
|
||||
const { minLength, minCount = 2, topN = 100, posFilterMode, customPosTags, enableStopwords, dictType, excludeWords } = options
|
||||
const {
|
||||
minLength,
|
||||
minCount = 2,
|
||||
topN = 100,
|
||||
posFilterMode,
|
||||
customPosTags,
|
||||
enableStopwords,
|
||||
dictType,
|
||||
excludeWords,
|
||||
} = options
|
||||
const wordFrequency = new Map<string, number>()
|
||||
const excludeSet = excludeWords?.length ? new Set(excludeWords.map((w) => w.toLowerCase())) : null
|
||||
|
||||
|
||||
@@ -226,9 +226,7 @@ export const chatApi = {
|
||||
/**
|
||||
* 获取支持的格式列表
|
||||
*/
|
||||
getSupportedFormats: (): Promise<
|
||||
Array<{ id: string; name: string; platform: string; extensions: string[] }>
|
||||
> => {
|
||||
getSupportedFormats: (): Promise<Array<{ id: string; name: string; platform: string; extensions: string[] }>> => {
|
||||
return ipcRenderer.invoke('chat:getSupportedFormats')
|
||||
},
|
||||
|
||||
|
||||
@@ -110,7 +110,9 @@ export const nlpApi = {
|
||||
return ipcRenderer.invoke('nlp:getPosTags')
|
||||
},
|
||||
|
||||
getDictList: (): Promise<Array<{ id: string; label: string; locale: string; downloaded: boolean; fileSize?: number }>> => {
|
||||
getDictList: (): Promise<
|
||||
Array<{ id: string; label: string; locale: string; downloaded: boolean; fileSize?: number }>
|
||||
> => {
|
||||
return ipcRenderer.invoke('nlp:getDictList')
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user