本文整理匯總了Java中eu.socialsensor.framework.client.search.visual.JsonResultSet類的典型用法代碼示例。如果您正苦於以下問題:Java JsonResultSet類的具體用法?Java JsonResultSet怎麽用?Java JsonResultSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JsonResultSet類屬於eu.socialsensor.framework.client.search.visual包,在下文中一共展示了JsonResultSet類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import eu.socialsensor.framework.client.search.visual.JsonResultSet; //導入依賴的package包/類
public void execute(Tuple tuple) {
try {
MediaItem mediaItem = (MediaItem) tuple.getValueByField("MediaItem");
if(mediaItem == null)
return;
String id = mediaItem.getId();
JsonResultSet response = _visualIndex.getSimilarImages(id, threshold);
List<JsonResult> results = response.getResults();
String nearestId = null;
for(JsonResult result : results) {
nearestId = result.getId();
if(id.equals(nearestId)) {
continue;
}
}
_mQ.offer(Pair.of(id, nearestId));
}
catch(Exception e) {
logger.error(e);
}
}
示例2: getMediaItemHistory
import eu.socialsensor.framework.client.search.visual.JsonResultSet; //導入依賴的package包/類
@Override
public List<MediaItem> getMediaItemHistory(String mediaItemId, int size) {
List<MediaItem> mediaItems = new ArrayList<MediaItem>();
Logger.getRootLogger().info("Get visually similar media items for " + mediaItemId);
int page = 1;
Set<String> ids = new HashSet<String>();
while (true) {
JsonResultSet similar = visualIndexHandler.getSimilarImages(mediaItemId, page++, 100);
if (similar != null && similar.getResults() != null && similar.getResults().size() > 0) {
List<JsonResult> results = similar.getResults();
for (JsonResult result : results) {
String mId = result.getId();
if (!ids.contains(mId)) {
MediaItem mediaItem = mediaItemDAO.getMediaItem(mId);
if (mediaItem != null) {
mediaItems.add(mediaItem);
}
}
}
} else {
break;
}
}
Logger.getRootLogger().info(mediaItems.size() + "media items retrieved. Re-rank by publication time");
Collections.sort(mediaItems, new Comparator<MediaItem>() {
public int compare(MediaItem mi1, MediaItem mi2) {
if (mi1.getPublicationTime() < mi2.getPublicationTime()) {
return 1;
} else {
return -1;
}
}
});
return mediaItems.subList(0, Math.min(size, mediaItems.size()));
}