dramaling-vocab-learning/backend/DramaLing.Api/Models/DTOs/AIAnalysisDto.cs

117 lines
4.0 KiB
C#

using System.ComponentModel.DataAnnotations;
namespace DramaLing.Api.Models.DTOs;
public class SentenceAnalysisRequest
{
[Required]
[StringLength(300, MinimumLength = 1, ErrorMessage = "輸入文本長度必須在1-300字符之間")]
public string InputText { get; set; } = string.Empty;
public string AnalysisMode { get; set; } = "full";
public AnalysisOptions? Options { get; set; }
}
public class AnalysisOptions
{
public bool IncludeGrammarCheck { get; set; } = true;
public bool IncludeVocabularyAnalysis { get; set; } = true;
public bool IncludeTranslation { get; set; } = true;
public bool IncludeIdiomDetection { get; set; } = true;
public bool IncludeExamples { get; set; } = true;
}
public class SentenceAnalysisResponse
{
public bool Success { get; set; } = true;
public double ProcessingTime { get; set; }
public SentenceAnalysisData? Data { get; set; }
public string? Message { get; set; }
}
public class SentenceAnalysisData
{
public string AnalysisId { get; set; } = Guid.NewGuid().ToString();
public string OriginalText { get; set; } = string.Empty;
public GrammarCorrectionDto? GrammarCorrection { get; set; }
public string SentenceMeaning { get; set; } = string.Empty;
public Dictionary<string, VocabularyAnalysisDto> VocabularyAnalysis { get; set; } = new();
public List<IdiomDto> Idioms { get; set; } = new();
public AnalysisMetadata Metadata { get; set; } = new();
}
public class GrammarCorrectionDto
{
public bool HasErrors { get; set; }
public string CorrectedText { get; set; } = string.Empty;
public List<GrammarErrorDto> Corrections { get; set; } = new();
}
public class GrammarErrorDto
{
public ErrorPosition Position { get; set; } = new();
public string Error { get; set; } = string.Empty;
public string Correction { get; set; } = string.Empty;
public string Type { get; set; } = string.Empty;
public string Explanation { get; set; } = string.Empty;
public string Severity { get; set; } = "medium";
}
public class ErrorPosition
{
public int Start { get; set; }
public int End { get; set; }
}
public class VocabularyAnalysisDto
{
public string Word { get; set; } = string.Empty;
public string Translation { get; set; } = string.Empty;
public string Definition { get; set; } = string.Empty;
public string PartOfSpeech { get; set; } = string.Empty;
public string Pronunciation { get; set; } = string.Empty;
public string DifficultyLevel { get; set; } = string.Empty;
public string Frequency { get; set; } = string.Empty;
public List<string> Synonyms { get; set; } = new();
public string? Example { get; set; }
public string? ExampleTranslation { get; set; }
}
public class IdiomDto
{
public string Idiom { get; set; } = string.Empty;
public string Translation { get; set; } = string.Empty;
public string Definition { get; set; } = string.Empty;
public string Pronunciation { get; set; } = string.Empty;
public string DifficultyLevel { get; set; } = string.Empty;
public string Frequency { get; set; } = string.Empty;
public List<string> Synonyms { get; set; } = new();
public string? Example { get; set; }
public string? ExampleTranslation { get; set; }
}
public class AnalysisMetadata
{
public string AnalysisModel { get; set; } = "gemini-1.5-flash";
public string AnalysisVersion { get; set; } = "2.0";
public DateTime ProcessingDate { get; set; } = DateTime.UtcNow;
}
public class ApiErrorResponse
{
public bool Success { get; set; } = false;
public ApiError Error { get; set; } = new();
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public string RequestId { get; set; } = Guid.NewGuid().ToString();
}
public class ApiError
{
public string Code { get; set; } = string.Empty;
public string Message { get; set; } = string.Empty;
public object? Details { get; set; }
public List<string> Suggestions { get; set; } = new();
}