本文整理汇总了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()));
}