/**
 * This function takes an article as input and calculates various statistics such as the total number of words,
 * the number of unique words, the number of sentences, and the frequency of each word in the article.
 *
 * @param article The article for which the statistics need to be calculated.
 * @return A dictionary containing the calculated statistics.
 */
fun getArticleStatistics(article: String): Map<String, Any> {

    // Counting the number of words, unique words, and sentences
    var wordCount = 0
    val uniqueWords = mutableSetOf<String>()
    var sentenceCount = 0

    // Splitting the article into words and counting them
    val words = article.split(" ")
    for (word in words) {
        wordCount++
        uniqueWords.add(word)
    }

    // Counting the number of sentences by checking for end punctuation marks
    for (char in article) {
        if (char in listOf('.', '!', '?')) {
            sentenceCount++
        }
    }

    // Calculating the word frequency
    val wordFrequency = mutableMapOf<String, Int>()
    for (word in words) {
        wordFrequency[word] = wordFrequency.getOrDefault(word, 0) + 1
    }

    return mapOf(
        "Total Words" to wordCount,
        "Unique Words" to uniqueWords.size,
        "Sentences" to sentenceCount,
        "Word Frequency" to wordFrequency
    )
}
/**
 * This function takes an article as input and calculates various statistics such as the total number of words,
 * the number of unique words, the number of sentences, and the frequency of each word in the article.
 *
 * @param article The article for which the statistics need to be calculated.
 * @return A dictionary containing the calculated statistics.
 */
fun getArticleStatistics(article: String): Map<String, Any> {
/**
 * This function takes an article as input and calculates various statistics such as the total number of words,
 * the number of unique words, the number of sentences, and the frequency of each word in the article.
 *
 * @param article The article for which the statistics need to be calculated.
 * @return A dictionary containing the calculated statistics.
 */
fun getArticleStatistics(article: String): Map<String, Any> {

    // Counting the number of words, unique words, and sentences
    var wordCount = 0
    val uniqueWords = mutableSetOf<String>()
    var sentenceCount = 0

    // Splitting the article into words and counting them
    val words = article.split(" ")
    for (word in words) {
        wordCount++
        uniqueWords.add(word)
    }

    // Counting the number of sentences by checking for end punctuation marks
    for (char in article) {
        if (char in listOf('.', '!', '?')) {
            sentenceCount++
        }
    }

    // Calculating the word frequency
    val wordFrequency = mutableMapOf<String, Int>()
    for (word in words) {
        wordFrequency[word] = wordFrequency.getOrDefault(word, 0) + 1
    }

    return mapOf(
        "Total Words" to wordCount,
        "Unique Words" to uniqueWords.size,
        "Sentences" to sentenceCount,
        "Word Frequency" to wordFrequency
    )
}