/**
 * This function takes an article title and a dictionary of themes and keywords, and returns the theme(s) that matches the keywords
 * found in the title. If multiple themes match the keywords, the function will return them separated by commas.
 *
 * @param articleTitle The title of the article.
 * @param articleDict The dictionary containing themes as keys and their corresponding keywords as values.
 * @return The matched theme(s) separated by commas.
 *
 * Example:
 * getArticleTheme("COVID-19 impacts global economy", mapOf("Health" to listOf("COVID-19", "pandemic"), "Economy" to listOf("global", "economic")))
 * Output: "Health, Economy"
 */
fun getArticleTheme(articleTitle: String, articleDict: Map<String, List<String>>): String {

    val matchedThemes = mutableListOf<String>()

    for ((theme, keywords) in articleDict) {
        if (keywords.any { keyword -> keyword.toLowerCase() in articleTitle.toLowerCase() }) {
            matchedThemes.add(theme)
        }
    }

    return matchedThemes.joinToString(", ")
}
/**
 * This function takes an article title and a dictionary of themes and keywords, and returns the theme(s) that matches the keywords
 * found in the title. If multiple themes match the keywords, the function will return them separated by commas.
 *
 * @param articleTitle The title of the article.
 * @param articleDict The dictionary containing themes as keys and their corresponding keywords as values.
 * @return The matched theme(s) separated by commas.
 *
 * Example:
 * getArticleTheme("COVID-19 impacts global economy", mapOf("Health" to listOf("COVID-19", "pandemic"), "Economy" to listOf("global", "economic")))
 * Output: "Health, Economy"
 */
fun getArticleTheme(articleTitle: String, articleDict: Map<String, List<String>>): String {
/**
 * This function takes an article title and a dictionary of themes and keywords, and returns the theme(s) that matches the keywords
 * found in the title. If multiple themes match the keywords, the function will return them separated by commas.
 *
 * @param articleTitle The title of the article.
 * @param articleDict The dictionary containing themes as keys and their corresponding keywords as values.
 * @return The matched theme(s) separated by commas.
 *
 * Example:
 * getArticleTheme("COVID-19 impacts global economy", mapOf("Health" to listOf("COVID-19", "pandemic"), "Economy" to listOf("global", "economic")))
 * Output: "Health, Economy"
 */
fun getArticleTheme(articleTitle: String, articleDict: Map<String, List<String>>): String {

    val matchedThemes = mutableListOf<String>()

    for ((theme, keywords) in articleDict) {
        if (keywords.any { keyword -> keyword.toLowerCase() in articleTitle.toLowerCase() }) {
            matchedThemes.add(theme)
        }
    }

    return matchedThemes.joinToString(", ")
}