-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathAnalyzer.java
42 lines (34 loc) · 1.27 KB
/
Analyzer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
public class Analyzer {
/**
* This method calculates the weighted average for each word in all the Sentences.
* This method is case-insensitive and all words should be stored in the Map using
* only lowercase letters.
*
* @param sentences Set containing Sentence objects with words to score
* @return Map of each word to its weighted average; or an empty Map if the Set of
* Sentences is empty or null.
*/
public static Map<String, Double> calculateWordScores(Set<Sentence> sentences) {
/*
* Implement this method in Part 2
*/
return null;
}
/**
* This method determines the sentiment of the input sentence using the average of the
* scores of the individual words, as stored in the Map.
* This method is case-insensitive and all words in the input sentence should be
* converted to lowercase before searching for them in the Map.
*
* @param wordScores Map of words to their weighted averages
* @param sentence Text for which the method calculates the sentiment
* @return Weighted average scores of all words in input sentence; or 0 if any error occurs
*/
public static double calculateSentenceScore(Map<String, Double> wordScores, String sentence) {
/*
* Implement this method in Part 3
*/
return 0;
}
}