Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save predictioniogists/6708196 to your computer and use it in GitHub Desktop.
Save predictioniogists/6708196 to your computer and use it in GitHub Desktop.
import io.prediction.ItemSimGetTopNRequestBuilder;
// You need to specify the name of the engine from which you want to retrieve the prediction results.
// Add the following code to display similar sightseeing spots to the user after arriving a destination:
String[] destinationIds;
try {
//retreive top 5 similar sightseeing spots from the item similarity engine
String[] itypes = {"sightseeing"}
ItemSimGetTopNRequestBuilder builder = client.getItemSimGetTopNRequestBuilder("the engine name", "arrived destination id", 5)
.itypes(itypes);
destinationIds = client.getItemSimTopN(builder);
} catch (Exception e) { // exception is raised when there is no prediction result.
destinationIds = getDefaultSightSeeingSpots(5); // eg. get nearest 5 sightseeing spots
handleException(e);
}
displaySightSeeingSpots(destinationIds); // display similar sightseeing spots to the user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment