}
final Map<String, Object> attributes = Maps.newHashMap();
CommonAttributesDescriptor.attributeBuilder(attributes)
.documents(documents);
final ProcessingResult englishResult = controller.process(
attributes, LingoClusteringAlgorithm.class);
ConsoleFormatter.displayResults(englishResult);
/*
* In the second call, we will fetch results for a Chinese query from Bing,
* setting explicitly the Bing's specific language attribute. Based on that
* attribute, the document source will set the appropriate language for each
* document.
*/
attributes.clear();
CommonAttributesDescriptor.attributeBuilder(attributes)
.query("聚类" /* clustering? */)
.results(100);
Bing3WebDocumentSourceDescriptor.attributeBuilder(attributes)
.market(MarketOption.CHINESE_CHINA);
Bing3WebDocumentSourceDescriptor
.attributeBuilder(attributes)
.appid(BingKeyAccess.getKey()); // use your own ID here!
final ProcessingResult chineseResult = controller.process(attributes,
Bing3WebDocumentSource.class, LingoClusteringAlgorithm.class);
ConsoleFormatter.displayResults(chineseResult);
/*
* In the third call, we will fetch results for the same Chinese query from
* Google. As Google document source does not have its specific attribute for
* setting the language, it will not set the documents' language for us. To make
* sure the right lexical resources are used, we will need to set the
* MultilingualClustering.defaultLanguage attribute to Chinese on our own.
*/
attributes.clear();
CommonAttributesDescriptor.attributeBuilder(attributes)
.query("聚类" /* clustering? */)
.results(100);
MultilingualClusteringDescriptor.attributeBuilder(attributes)
.defaultLanguage(LanguageCode.CHINESE_SIMPLIFIED);
final ProcessingResult chineseResult2 = controller.process(attributes,
GoogleDocumentSource.class, LingoClusteringAlgorithm.class);
ConsoleFormatter.displayResults(chineseResult2);
// [[[end:clustering-non-english-content]]]
}