package main
import (
"fmt"
"strings"
"github.com/arbovm/levenshtein"
)
func main() {
word1 := "hello"
word2 := "world"
// Step 1: Check if the two words are equal
if word1 == word2 {
fmt.Println("Step 1: Words are equal.")
} else {
fmt.Println("Step 1: Words are not equal.")
}
// Step 2: Calculate the Levenshtein distance between the words
distance := levenshtein.Distance(word1, word2)
fmt.Printf("Step 2: Levenshtein distance between words: %d\n", distance)
// Step 3: Convert words to lowercase for case-insensitive comparison
word1Lower := strings.ToLower(word1)
word2Lower := strings.ToLower(word2)
// Step 4: Check if the lowercase words are equal
if word1Lower == word2Lower {
fmt.Println("Step 4: Lowercase words are equal.")
} else {
fmt.Println("Step 4: Lowercase words are not equal.")
}
// Step 5: Check if one word contains the other
if strings.Contains(word1, word2) || strings.Contains(word2, word1) {
fmt.Println("Step 5: One word contains the other.")
} else {
fmt.Println("Step 5: Words do not contain each other.")
}
// Step 6: Check if the words are synonyms using a thesaurus (not implemented here)
// Example API call: https://api.datamuse.com/words?rel_syn=hello
// Assume the API returns a list of synonyms
synonyms := []string{"hi", "greetings", "hey"}
for _, synonym := range synonyms {
if word1Lower == synonym || word2Lower == synonym {
fmt.Println("Step 6: Words are synonyms.")
break
}
}
// Step 7: Check if the words rhyme (not implemented here)
// Example API call: https://api.datamuse.com/words?rel_rhy=hello
// Assume the API returns a list of rhyming words
rhymingWords := []string{"fellow", "mellow", "yellow"}
for _, rhymingWord := range rhymingWords {
if word1Lower == rhymingWord || word2Lower == rhymingWord {
fmt.Println("Step 7: Words rhyme.")
break
}
}
}