diff --git a/AI生成功能前後端串接規格.md b/AI生成功能前後端串接規格.md index ff8a9c4..f3a7cac 100644 --- a/AI生成功能前後端串接規格.md +++ b/AI生成功能前後端串接規格.md @@ -110,7 +110,7 @@ const handleAnalyzeSentence = async () => { includeGrammarCheck: true, includeVocabularyAnalysis: true, includeTranslation: true, - includePhraseDetection: true, + includeIdiomDetection: true, includeExamples: true } }) @@ -163,7 +163,7 @@ public async Task> AnalyzeSentence( "includeGrammarCheck": true, "includeVocabularyAnalysis": true, "includeTranslation": true, - "includePhraseDetection": true, + "includeIdiomDetection": true, "includeExamples": true } } @@ -206,7 +206,6 @@ public async Task> AnalyzeSentence( "partOfSpeech": "pronoun", "pronunciation": "/ʃiː/", "difficultyLevel": "A1", - "isPhrase": false, "frequency": "very_high", "synonyms": ["her"], "example": "She is a teacher.", @@ -220,7 +219,6 @@ public async Task> AnalyzeSentence( "partOfSpeech": "idiom", "pronunciation": "/kʌt ˈsʌmwʌn sʌm slæk/", "difficultyLevel": "B2", - "isPhrase": true, "frequency": "medium", "synonyms": ["be lenient", "be forgiving", "give leeway"], "example": "Cut him some slack, he's new here.", @@ -234,7 +232,7 @@ public async Task> AnalyzeSentence( "simpleWords": 8, "moderateWords": 4, "difficultWords": 3, - "phrases": 1, + "idioms": 1, "averageDifficulty": "A2" }, "metadata": { @@ -291,8 +289,7 @@ const getWordClass = useCallback((word: string) => { if (!wordAnalysis) return "" - const isPhrase = getWordProperty(wordAnalysis, 'isPhrase') - if (isPhrase) return "" + // 慣用語不在句子中顯示標記,統一在慣用語區域展示 const difficultyLevel = getWordProperty(wordAnalysis, 'difficultyLevel') || 'A1' const userLevel = typeof window !== 'undefined' ? localStorage.getItem('userEnglishLevel') || 'A2' : 'A2' @@ -319,15 +316,13 @@ const vocabularyStats = useMemo(() => { if (!sentenceAnalysis) return null const userLevel = localStorage.getItem('userEnglishLevel') || 'A2' - let simpleCount = 0, moderateCount = 0, difficultCount = 0, phraseCount = 0 + let simpleCount = 0, moderateCount = 0, difficultCount = 0, idiomCount = 0 Object.entries(sentenceAnalysis).forEach(([, wordData]: [string, any]) => { - const isPhrase = wordData?.isPhrase || wordData?.IsPhrase + // 慣用語由獨立的 idioms 陣列處理,不在 vocabularyAnalysis 中 const difficultyLevel = wordData?.difficultyLevel || 'A1' - if (isPhrase) { - phraseCount++ - } else { + // 所有 vocabularyAnalysis 中的詞彙都是一般詞彙,無慣用語 const userIndex = getLevelIndex(userLevel) const wordIndex = getLevelIndex(difficultyLevel) @@ -341,7 +336,8 @@ const vocabularyStats = useMemo(() => { } }) - return { simpleCount, moderateCount, difficultCount, phraseCount } + // idiomCount 由獨立的 idioms 陣列長度計算 + return { simpleCount, moderateCount, difficultCount, idiomCount: sentenceAnalysis.idioms?.length || 0 } }, [sentenceAnalysis]) ``` @@ -404,7 +400,7 @@ private string BuildAnalysisPrompt(string inputText, string userLevel, AnalysisO 詞彙分析要求: - 為每個詞彙標註CEFR等級 (A1-C2) -- 如果是慣用語,設置 isPhrase: true +- 慣用語單獨放在 idioms 陣列中,不在 vocabularyAnalysis 中 - 提供IPA發音標記 - 包含同義詞 - 提供適當的例句和翻譯 @@ -512,7 +508,7 @@ return ( {/* 慣用語卡片 */}
-
{vocabularyStats.phraseCount}
+
{vocabularyStats.idiomCount}
慣用語
diff --git a/AI生成功能後端API規格.md b/AI生成功能後端API規格.md index f4a60de..d2b0654 100644 --- a/AI生成功能後端API規格.md +++ b/AI生成功能後端API規格.md @@ -85,7 +85,7 @@ Authorization: Bearer {token} "includeGrammarCheck": true, "includeVocabularyAnalysis": true, "includeTranslation": true, - "includePhraseDetection": true, + "includeIdiomDetection": true, "includeExamples": true } } @@ -138,7 +138,6 @@ Authorization: Bearer {token} "partOfSpeech": "pronoun", "pronunciation": "/ʃiː/", "difficultyLevel": "A1", - "isPhrase": false, "frequency": "very_high", "synonyms": ["her"], "example": "She is a teacher.", @@ -152,35 +151,37 @@ Authorization: Bearer {token} "partOfSpeech": "adverb", "pronunciation": "/dʒʌst/", "difficultyLevel": "A2", - "isPhrase": false, "frequency": "high", "synonyms": ["recently", "only", "merely"], "example": "I just arrived.", "exampleTranslation": "我剛到。", "tags": ["time", "adverb"] - }, - "cut someone some slack": { - "word": "cut someone some slack", - "translation": "對某人寬容一點", - "definition": "to be more lenient or forgiving with someone", - "partOfSpeech": "idiom", - "pronunciation": "/kʌt ˈsʌmwʌn sʌm slæk/", - "difficultyLevel": "B2", - "isPhrase": true, - "frequency": "medium", - "synonyms": ["be lenient", "be forgiving", "give leeway"], - "example": "Cut him some slack, he's new here.", - "exampleTranslation": "對他寬容一點,他是新來的。", - "tags": ["idiom", "workplace", "tolerance"] } }, + "idioms": [ + { + "idiom": "cut someone some slack", + "translation": "對某人寬容一點", + "definition": "to be more lenient or forgiving with someone", + "pronunciation": "/kʌt ˈsʌmwʌn səm slæk/", + "difficultyLevel": "B2", + "frequency": "medium", + "synonyms": [ + "give someone a break", + "go easy on someone", + "let someone off the hook" + ], + "example": "Cut him some slack, he's new here.", + "exampleTranslation": "對他寬容一點,他是新來的。" + } + ], "statistics": { "totalWords": 16, "uniqueWords": 15, "simpleWords": 8, "moderateWords": 4, "difficultWords": 3, - "phrases": 1, + "idioms": 1, "averageDifficulty": "A2" }, "metadata": { @@ -223,7 +224,6 @@ interface VocabularyAnalysis { partOfSpeech: string // 詞性 pronunciation: string // 發音 (IPA) difficultyLevel: CEFRLevel // CEFR等級 - isPhrase: boolean // 是否為慣用語 frequency: FrequencyLevel // 使用頻率 synonyms: string[] // 同義詞 example?: string // 例句 diff --git a/AI生成網頁前端實際功能規格.md b/AI生成網頁前端實際功能規格.md deleted file mode 100644 index 2d30eac..0000000 --- a/AI生成網頁前端實際功能規格.md +++ /dev/null @@ -1,590 +0,0 @@ -# AI生成網頁前端實際功能規格 - -## 📋 **文件資訊** - -- **文件名稱**: AI生成網頁前端實際功能規格 -- **版本**: v1.0 (基於現行實現) -- **建立日期**: 2025-09-22 -- **最後更新**: 2025-09-22 -- **基於**: 需求規格文檔 + 實際前端畫面 - ---- - -## 🎯 **實際功能概述** - -基於當前 `/generate` 頁面的實際實現,本文檔記錄已完成的功能規格,確保文檔與實際產品100%一致。 - ---- - -## 🔧 **已實現功能規格** - -### **F1. 文本輸入分析系統** - -#### **F1.1 輸入界面 ✅** -**實現狀態**: 完全實現 - -**功能特色**: -- **字符限制**: 300字符(手動模式) -- **即時計數**: 顯示"最多 300 字元 • 目前:X 字元" -- **視覺警告**: - - 280字符:黃色邊框 `border-yellow-400` - - 300字符:紅色邊框 `border-red-400`,阻止輸入 -- **響應式設計**: `h-32 sm:h-40` - -**實際HTML結構**: -```tsx -