import java.io.
*;
import java.util.*;
public class Problem3 {
public static void main(String[] args) {
String fileName = "sample.txt";
Map<String, Integer> wordCountMap = new HashMap<>();
try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
String line;
while ((line = br.readLine()) != null) {
line = line.toLowerCase().replaceAll("[^a-zA-Z0-9\\s]", "");
String[] words = line.split("\\s+");
for (String word : words) {
if (!word.isEmpty()) {
wordCountMap.put(word, wordCountMap.getOrDefault(word, 0) + 1);
}
}
}
} catch (IOException e) {
System.out.println("Error reading file: " + e.getMessage());
}
System.out.println("Word Frequency Count:");
wordCountMap.forEach((word, count) -> System.out.println(word + ": " + count));
}
}