0
Java
java code for counting the frequency of each word in a paragraph taken from the user
3 Answers
+ 3
Orion hi,
This logic might help you to make complete code
//map is used here to map the integer float function
public static Map<Integer, Long> countLetters(String filename) throws IOException {
//fetching fine lines
return Files.lines(Paths.get(filename))
//mapping of string to character and character to letter
.flatMapToInt(String::chars)
.filter(Character::isLetter)
.boxed()
//collect all character and group them by their counting
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
}
And if you are an beginner then use this for loop for iteration of the code
//loop for reading character value till null
while((line = in.readLine()) != null){
//convert to uppercase
line = line.toUpperCase();
//convert string into character array
for(char ch:line.toCharArray()){
//counting of each character
if(Character.isLetter(ch)){
freqs[ch - 'A']++;
}
}
}
any further query ping me I'll loved to answer with some more examples
Have these đ đ đ đ
0
Try doing it on your own, even if you don't do much and we will try to fix/help you with your code!
0
thnx