/**
 * Given a text consisting of multiple sentences, this function finds the indices of the sentences where a given word
 * appears. The function returns a dictionary where the keys are the sentences that contain the word and the values are
 * the corresponding indices.
 *
 * @param text The input text consisting of multiple sentences.
 * @param word The word to be searched in the sentences.
 * @return A dictionary where the keys represent the sentences containing the word and the values are the indices of those
 * sentences.
 */
fun findWordInSentences(text: String, word: String): Map<String, Int> {

    val sentences = text.split('.') // Split the text into individual sentences
    val wordIndices = mutableMapOf<String, Int>() // Dictionary to store the indices of sentences containing the word

    for ((index, sentence) in sentences.withIndex()) {
        val words = sentence.trim().split(' ')

        // Search for the given word in the current sentence
        if (word in words) {
            wordIndices[sentence] = index

            // Break out of the loop if the word is found in all the sentences
            if (wordIndices.size == sentences.size) {
                break
            }
        }
    }

    return wordIndices
}
/**
 * Given a text consisting of multiple sentences, this function finds the indices of the sentences where a given word
 * appears. The function returns a dictionary where the keys are the sentences that contain the word and the values are
 * the corresponding indices.
 *
 * @param text The input text consisting of multiple sentences.
 * @param word The word to be searched in the sentences.
 * @return A dictionary where the keys represent the sentences containing the word and the values are the indices of those
 * sentences.
 */
fun findWordInSentences(text: String, word: String): Map<String, Int> {
/**
 * Given a text consisting of multiple sentences, this function finds the indices of the sentences where a given word
 * appears. The function returns a dictionary where the keys are the sentences that contain the word and the values are
 * the corresponding indices.
 *
 * @param text The input text consisting of multiple sentences.
 * @param word The word to be searched in the sentences.
 * @return A dictionary where the keys represent the sentences containing the word and the values are the indices of those
 * sentences.
 */
fun findWordInSentences(text: String, word: String): Map<String, Int> {

    val sentences = text.split('.') // Split the text into individual sentences
    val wordIndices = mutableMapOf<String, Int>() // Dictionary to store the indices of sentences containing the word

    for ((index, sentence) in sentences.withIndex()) {
        val words = sentence.trim().split(' ')

        // Search for the given word in the current sentence
        if (word in words) {
            wordIndices[sentence] = index

            // Break out of the loop if the word is found in all the sentences
            if (wordIndices.size == sentences.size) {
                break
            }
        }
    }

    return wordIndices
}