| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import Foundation
- struct DictionaryEntry: Identifiable, Equatable {
- let id = UUID()
- let word: String
- let phonetic: String?
- let audioURL: URL?
- let meanings: [DictionaryMeaning]
- }
- struct DictionaryMeaning: Identifiable, Equatable {
- let id = UUID()
- let partOfSpeech: String
- let definitions: [DictionaryDefinition]
- let synonyms: [String]
- let antonyms: [String]
- }
- struct DictionaryDefinition: Identifiable, Equatable {
- let id = UUID()
- let text: String
- let example: String?
- }
- enum DictionaryServiceError: LocalizedError {
- case missingAPIKey
- case emptyInput
- case wordNotFound
- case invalidResponse
- case networkError(String)
- var errorDescription: String? {
- switch self {
- case .missingAPIKey:
- "OpenAI API key is missing."
- case .emptyInput:
- "Enter a word to look up."
- case .wordNotFound:
- "No definition found for that word."
- case .invalidResponse:
- "Could not read the dictionary response."
- case .networkError(let message):
- message
- }
- }
- }
|