yahoo search api and autocorrection
in
Contributed Library Questions
•
2 years ago
Hello there,
i`m playing with yahoo! search api and it mostly works fine.
I´m doing querys and want to work with the numer of results. I need the number of results which fit the exact spelling of the word (very important) but the results i get includes other (autocorrected) spellings too.
I need to switch that autocorrection of but don`t know how.
** CODE **
// Replace this with a developer key from
http://developer.yahoo.com
String appid = "Derp"; //no need for a key ?
SearchClient client = new SearchClient(appid);
String query = "expres" ;
WebSearchRequest request = new WebSearchRequest(query);
//request.setLanguage("de"); // Language to search in > German
//request.setCountry("de"); // Country to search in > German
//request.setSimilarOk(false); // no Similiar contents
// (Optional) Set the maximum number of results to download
//request.setResults(30);
try {
WebSearchResults results = client.webSearch(request);
// SpellingSuggestionResults spellings = spelling.webSearch(request);
// Print out how many hits were found
println("Displaying " + results.getTotalResultsReturned() +
" out of " + results.getTotalResultsAvailable() + " hits.");
println();
// Get a list of the search results
WebSearchResult[] resultList = results.listResults();
// Loop through the results and print them to the console
for (int i = 0; i < resultList.length; i++) {
// Print out the document title and URL.
println((i + 1) + ".");
println(resultList[i].getTitle());
println(resultList[i].getUrl());
println();
}
// Error handling below, see the documentation of the Yahoo! API for details
}
catch (IOException e) {
println("Error calling Yahoo! Search Service: " + e.toString());
e.printStackTrace();
}
catch (SearchException e) {
println("Error calling Yahoo! Search Service: " + e.toString());
e.printStackTrace();
}
**
IMPORTANT: you have to add »yahoo_search-2.0.1.jar« to the sketch
-> Reference for Yahoo Search API
Maybe somebody can help or got other ideas how to get the exact number of results for a phrase.
Thanks in Advance
simon
1