/**
 * The function updates the statistics of each article in the articlesData dictionary.
 *
 * @param articlesData A nested dictionary containing the details of each article.
 */
fun updateArticleStats(articlesData: MutableMap<String, MutableMap<String, Any>>) {

    // Iterate over the articles in the outer dictionary
    for ((articleId, articleInfo) in articlesData) {
        println("Analyzing article with ID: $articleId")

        // Retrieve the number of comments for the article
        val commentsCount = articleInfo["comments_count"] as Int?

        // Retrieve the number of views for the article
        val viewsCount = articleInfo["views_count"] as Int?

        // Calculate the engagement score for the article
        val engagementScore = commentsCount?.toDouble()?.div(viewsCount ?: 1) ?: 0.0

        // Update the article's statistics
        articleInfo["engagement_score"] = engagementScore

        // If the engagementScore is less than 0.05, skip further analysis
        if (engagementScore < 0.05) {
            continue
        }

        // Iterate over the comments in the inner dictionary
        val comments = articleInfo["comments"] as? MutableMap<String, MutableMap<String, Any>> ?: mutableMapOf()
        for ((commentId, commentInfo) in comments) {
            println("Analyzing comment with ID: $commentId")
        }
    }
}
/**
 * The function updates the statistics of each article in the articlesData dictionary.
 *
 * @param articlesData A nested dictionary containing the details of each article.
 */
fun updateArticleStats(articlesData: MutableMap<String, MutableMap<String, Any>>) {
/**
 * The function updates the statistics of each article in the articlesData dictionary.
 *
 * @param articlesData A nested dictionary containing the details of each article.
 */
fun updateArticleStats(articlesData: MutableMap<String, MutableMap<String, Any>>) {

    // Iterate over the articles in the outer dictionary
    for ((articleId, articleInfo) in articlesData) {
        println("Analyzing article with ID: $articleId")

        // Retrieve the number of comments for the article
        val commentsCount = articleInfo["comments_count"] as Int?

        // Retrieve the number of views for the article
        val viewsCount = articleInfo["views_count"] as Int?

        // Calculate the engagement score for the article
        val engagementScore = commentsCount?.toDouble()?.div(viewsCount ?: 1) ?: 0.0

        // Update the article's statistics
        articleInfo["engagement_score"] = engagementScore

        // If the engagementScore is less than 0.05, skip further analysis
        if (engagementScore < 0.05) {
            continue
        }

        // Iterate over the comments in the inner dictionary
        val comments = articleInfo["comments"] as? MutableMap<String, MutableMap<String, Any>> ?: mutableMapOf()
        for ((commentId, commentInfo) in comments) {
            println("Analyzing comment with ID: $commentId")
        }
    }
}