diff --git a/backend/DramaLing.Api/Controllers/AIController.cs b/backend/DramaLing.Api/Controllers/AIController.cs
index b1edd9b..6e3f029 100644
--- a/backend/DramaLing.Api/Controllers/AIController.cs
+++ b/backend/DramaLing.Api/Controllers/AIController.cs
@@ -635,53 +635,23 @@ public class AIController : ControllerBase
return BadRequest(new { Success = false, Error = "Word is required" });
}
- // 模擬檢查是否為高價值詞彙
- var isHighValue = IsHighValueWord(request.Word, request.Sentence);
+ // 簡化邏輯:直接調用 GeminiService 進行詞彙分析
+ var wordAnalysis = await _geminiService.AnalyzeWordAsync(request.Word, request.Sentence);
- if (isHighValue)
+ return Ok(new
{
- return Ok(new
+ Success = true,
+ Data = new
{
- Success = true,
- Data = new
- {
- Word = request.Word,
- IsHighValue = true,
- WasPreAnalyzed = true,
- CostIncurred = 0,
- Analysis = GetHighValueWordAnalysis(request.Word)
- },
- Message = "高價值詞彙查詢完成(免費)"
- });
- }
- else
- {
- // 低價值詞彙需要即時分析
- var analysis = await AnalyzeLowValueWord(request.Word, request.Sentence);
-
- return Ok(new
- {
- Success = true,
- Data = new
- {
- Word = request.Word,
- IsHighValue = false,
- WasPreAnalyzed = false,
- CostIncurred = 1,
- Analysis = analysis,
- UsageStatistics = new
- {
- RemainingAnalyses = 3, // 模擬扣除後剩餘
- CostType = "word_query"
- }
- },
- Message = "低價值詞彙查詢完成"
- });
- }
+ Word = request.Word,
+ Analysis = wordAnalysis
+ },
+ Message = "詞彙分析完成"
+ });
}
catch (Exception ex)
{
- _logger.LogError(ex, "Error in word query");
+ _logger.LogError(ex, "Error analyzing word: {Word}", request.Word);
return StatusCode(500, new
{
Success = false,
@@ -943,111 +913,11 @@ public class AIController : ControllerBase
};
}
- ///
- /// 檢查是否為高價值詞彙
- ///
- private bool IsHighValueWord(string word, string sentence)
- {
- var highValueWords = new[] { "brought", "up", "meeting", "agreed", "went", "yesterday", "met", "friends" };
- return highValueWords.Contains(word.ToLower());
- }
+ // 移除 IsHighValueWord 方法,改用 AI 智能判定
- ///
- /// 獲取高價值詞彙分析
- ///
- private object GetHighValueWordAnalysis(string word)
- {
- // 模擬高價值詞彙的預分析資料
- return new
- {
- word = word,
- translation = "預分析的翻譯",
- definition = "預分析的定義",
- partOfSpeech = "verb",
- pronunciation = "/example/",
- synonyms = new[] { "example1", "example2" },
- antonyms = new[] { "opposite1" },
- isPhrase = false,
- isHighValue = true,
- learningPriority = "high",
- difficultyLevel = "B1"
- };
- }
+ // 移除 GetHighValueWordAnalysis 方法,改用真實 AI 分析
- ///
- /// 分析低價值詞彙
- ///
- private async Task