FogHorn Systems processes text associated with industrial alerts. Given a sentence and two target words, return the minimum distance between any occurrence of the targets.
Treat each maximal sequence of English letters as one word, ignore punctuation, and compare words case-insensitively. A word's position is its zero-based index in the normalized token list. The distance between two occurrences is the absolute difference between their positions. If the target words are identical, use two distinct occurrences. Return -1 if either target cannot be found or if identical targets occur fewer than two times.
Implement min_word_distance(sentence, word1, word2).
sentence, a string; word1 and word2, non-empty strings containing English letters.-1 when no valid pair exists.def min_word_distance(sentence, word1, word2):