/**
 * This function takes in a dictionary representing an article and extracts its relevant information.
 *
 * @param article A dictionary containing details of an article, including its title, author, and content.
 * @return A tuple containing the title, author, and the number of words in the article.
 * @throws IllegalArgumentException If the article dictionary is missing any required fields.
 * @throws IllegalArgumentException If the content of the article is not a string.
 */
fun getArticleInfo(article: Map<String, Any>): Triple<String, String, Int> {

    val title = article["title"] as? String ?: throw IllegalArgumentException("Article dictionary is missing 'title' field.")
    val author = article["author"] as? String ?: throw IllegalArgumentException("Article dictionary is missing 'author' field.")
    val content = article["content"] as? String ?: throw IllegalArgumentException("Article dictionary is missing 'content' field.")
    
    if (!content.all { it.isLetterOrDigit() || it.isWhitespace() }) {
        throw IllegalArgumentException("Content should be a string.")
    }
    
    val words = content.split("\\s+".toRegex()).size
    return Triple(title, author, words)
}
/**
 * This function takes in a dictionary representing an article and extracts its relevant information.
 *
 * @param article A dictionary containing details of an article, including its title, author, and content.
 * @return A tuple containing the title, author, and the number of words in the article.
 * @throws IllegalArgumentException If the article dictionary is missing any required fields.
 * @throws IllegalArgumentException If the content of the article is not a string.
 */
fun getArticleInfo(article: Map<String, Any>): Triple<String, String, Int> {
/**
 * This function takes in a dictionary representing an article and extracts its relevant information.
 *
 * @param article A dictionary containing details of an article, including its title, author, and content.
 * @return A tuple containing the title, author, and the number of words in the article.
 * @throws IllegalArgumentException If the article dictionary is missing any required fields.
 * @throws IllegalArgumentException If the content of the article is not a string.
 */
fun getArticleInfo(article: Map<String, Any>): Triple<String, String, Int> {

    val title = article["title"] as? String ?: throw IllegalArgumentException("Article dictionary is missing 'title' field.")
    val author = article["author"] as? String ?: throw IllegalArgumentException("Article dictionary is missing 'author' field.")
    val content = article["content"] as? String ?: throw IllegalArgumentException("Article dictionary is missing 'content' field.")
    
    if (!content.all { it.isLetterOrDigit() || it.isWhitespace() }) {
        throw IllegalArgumentException("Content should be a string.")
    }
    
    val words = content.split("\\s+".toRegex()).size
    return Triple(title, author, words)
}