public class Search extends Object
PS1 instructions: do NOT change the method signatures or specifications of these methods, but you should implement their method bodies, and you may add new public or private methods or classes if you like.
| Modifier and Type | Method and Description |
|---|---|
static Map<PointOfInterest,List<PointOfInterest>> |
reduceDuplicates(List<PointOfInterest> pointsOfInterest)
Guess which points of interest (POIs) are duplicates that represent the
same physical place.
|
static Set<PointOfInterest> |
search(Map<PointOfInterest,List<PointOfInterest>> pointOfInterestMap,
Set<String> keywords)
Search for points of interest that match keywords.
|
public static Map<PointOfInterest,List<PointOfInterest>> reduceDuplicates(List<PointOfInterest> pointsOfInterest)
This method identifies groups of POIs in the input list that appear to be duplicative, and picks a best entry from the group. That entry is a key in the returned map, and its value is a list of the other duplicates in the group.
POIs are identified as duplicates if and only if their location, name, and/or description provide evidence that they represent the same physical place. POIs whose latitude, longitude, and name are .equals() must be identified as duplicates. Other evidence may be used at the implementor's discretion.
pointsOfInterest - a list of POIs, not modified by this methodpublic static Set<PointOfInterest> search(Map<PointOfInterest,List<PointOfInterest>> pointOfInterestMap, Set<String> keywords)
pointOfInterestMap - a map whose keys are the POIs that can be returned by this method,
and whose value lists contain alternative POIs that can be used to match
the keywords. For example, a key POI might be named "Great Dome", and
its value list might include POIs with descriptions "Lobby 10" or
"Barker Library".keywords - keywords to search for. Must be nonempty strings of letters (A-Z, a-z),
digits (0-9), underscores ("_"), hyphens ("-"), or spaces (" ").
Keywords are treated case-insensitively for matching, so "dome"
is the same as "DOME", and the name "Great Dome" matches either one.