本文整理汇总了Java中eu.socialsensor.framework.common.domain.MediaItem类的典型用法代码示例。如果您正苦于以下问题:Java MediaItem类的具体用法?Java MediaItem怎么用?Java MediaItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaItem类属于eu.socialsensor.framework.common.domain包,在下文中一共展示了MediaItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
@Override
public void execute(Tuple tuple) {
try {
MediaItem mediaItem = (MediaItem) tuple.getValueByField("MediaItem");
if(mediaItem == null) {
return;
}
Jedis jedis = _pool.getResource();
String mId = mediaItem.getId();
String value = jedis.hget(mId, "STATUS");
if(value == null) {
collector.emit(tuple(mediaItem));
jedis.hset(mId, "STATUS", "INJECTED");
}
_pool.returnResource(jedis);
}
catch(Exception e) {
_logger.error(e);
}
}
开发者ID:socialsensor,项目名称:storm-focused-crawler,代码行数:26,代码来源:StatusCheckBolt.java
示例2: prepare
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
public void prepare(@SuppressWarnings("rawtypes") Map stormConf, TopologyContext context,
OutputCollector collector) {
_logger = Logger.getLogger(ConceptDetectionBolt.class);
_collector = collector;
queue = new LinkedBlockingQueue<Pair<ImageVector, MediaItem>>();
try {
_detector = new ConceptDetector(matlabFile);
conceptDetectionTask = new ConceptDetectionTask(queue);
conceptDetectionThread = new Thread(conceptDetectionTask);
conceptDetectionThread.start();
}
catch(Exception e) {
_logger.fatal(e);
}
}
开发者ID:socialsensor,项目名称:storm-focused-crawler,代码行数:21,代码来源:ConceptDetectionBolt.java
示例3: getMediaItem
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
public MediaItem getMediaItem(String shortId) {
GenericUrl requestUrl = new GenericUrl(requestPrefix + shortId);
HttpRequest request;
try {
request = requestFactory.buildGetRequest(requestUrl);
HttpResponse response = request.execute();
TwitPicImage image = response.parseAs(TwitPicImage.class);
if(image != null) {
MediaItem mediaItem = new TwitPicMediaItem(image);
return mediaItem;
}
} catch (Exception e) {
}
return null;
}
开发者ID:socialsensor,项目名称:socialmedia-abstractions,代码行数:19,代码来源:TwitpicRetriever.java
示例4: execute
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
public void execute(Tuple tuple) {
try {
MediaItem mediaItem = (MediaItem) tuple.getValueByField("MediaItem");
if(mediaItem == null || _solrMediaHandler == null)
return;
queue.add(mediaItem);
}
catch(Exception ex) {
ex.printStackTrace();
logger.error(ex);
}
}
开发者ID:socialsensor,项目名称:storm-focused-crawler,代码行数:17,代码来源:MediaTextIndexerBolt.java
示例5: run
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
public void run() {
while(true) {
try {
// Just wait 15 seconds
Thread.sleep(15 * 1000);
List<MediaItem> mItems = new ArrayList<MediaItem>();
queue.drainTo(mItems);
if(mItems.isEmpty())
continue;
boolean inserted = _solrMediaHandler.insertMediaItems(mItems);
if(inserted) {
logger.info(mItems.size() + " media items indexed in Solr.");
}
else {
logger.error("Indexing in Solr failed for some media items.");
}
} catch (Exception e) {
logger.error(e);
continue;
}
}
}
开发者ID:socialsensor,项目名称:storm-focused-crawler,代码行数:27,代码来源:MediaTextIndexerBolt.java
示例6: run
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
public void run() {
while(true) {
Object obj = _tupleQueue.poll();
if(obj != null) {
synchronized(_collector) {
if(MediaItem.class.isInstance(obj)) {
mediaTuples++;
_collector.emit(MEDIA_STREAM, tuple(obj));
}
else if(WebPage.class.isInstance(obj)) {
webPagesTuples++;
_collector.emit(WEBPAGE_STREAM, tuple(obj));
}
}
}
else {
Utils.sleep(500);
}
if((mediaTuples%100==0 || webPagesTuples%100==0) && (mediaTuples!=0 || webPagesTuples!=0)) {
_logger.info(receivedTuples + " tuples received, " + mediaTuples + " media tuples emmited, " +
webPagesTuples + " web page tuples emmited");
_logger.info(getWorkingFetchers() + " fetchers out of " + numOfFetchers + " are working.");
}
}
}
开发者ID:socialsensor,项目名称:storm-focused-crawler,代码行数:27,代码来源:ArticleExtractionBolt.java
示例7: featureExtractionMedia
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
/**
* Function that performs Item and User feature extraction of a MediaItem
* @param listMediaItems the list of MediaItems need to be extracted
* @return TotalFeatures list of the features extracted
* @throws Exception
*/
public static List<TotalFeatures> featureExtractionMedia(List<MediaItem> listMediaItems) throws Exception {
//extract features of the items
List<ItemFeatures> itemFeatures = ItemFeaturesExtractor.featureExtractionMedia(listMediaItems);
//extract user features of the items
List<UserFeatures> itemUserFeatures = UserFeaturesExtractor.userFeatureExtractionMedia(listMediaItems);
List<TotalFeatures> totalFeatures = new ArrayList<TotalFeatures>();
for (int i=0;i<itemFeatures.size();i++){
TotalFeatures totFeat = extractTotalFeatures(itemFeatures.get(i),itemUserFeatures.get(i));
totalFeatures.add(totFeat);
}
return totalFeatures;
}
开发者ID:socialsensor,项目名称:computational-verification,代码行数:24,代码来源:TotalFeaturesExtractor.java
示例8: performCrossValidationExample
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
/**
* Auxiliary function to organize the cross validation process
* Calls the appropriate crossValidate method depending on the features (Item, User or Total)
* @throws Exception
*/
public static void performCrossValidationExample() throws Exception{
//get fake items
MediaItemDAOImpl daof = new MediaItemDAOImpl("ip", "dbname", "collectionname");
List<MediaItem> itemsFake = daof.getLastMediaItems(100);
//get real items
MediaItemDAOImpl daor = new MediaItemDAOImpl("ip", "dbname", "collectionname");
List<MediaItem> itemsReal = daor.getLastMediaItems(100);
try {
ItemClassifier.crossValidate(itemsFake, itemsReal);
UserClassifier.crossValidate(itemsFake, itemsReal);
TotalClassifier.crossValidate(itemsFake, itemsReal);
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:socialsensor,项目名称:computational-verification,代码行数:24,代码来源:TweetClassifier.java
示例9: getMediaItem
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
/**
* Returns the retrieved media item
*/
public MediaItem getMediaItem(String id) {
DailyMotionUrl url = new DailyMotionUrl(requestPrefix + id);
HttpRequest request;
try {
request = requestFactory.buildGetRequest(url);
DailyMotionVideo video = request.execute().parseAs(DailyMotionVideo.class);
if(video != null) {
MediaItem mediaItem = new DailyMotionMediaItem(video);
return mediaItem;
}
} catch (Exception e) {
}
return null;
}
开发者ID:socialsensor,项目名称:socialmedia-abstractions,代码行数:24,代码来源:DailyMotionRetriever.java
示例10: getMediaItemsByDysco
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
@Override
public List<MediaItem> getMediaItemsByDysco(String dyscoId, String mediaType, int size) {
Selector query = new Selector();
query.select("dyscoId", dyscoId);
query.select("type", mediaType);
List<String> results = mongoHandler.findMany(query, size);
List<MediaItem> mediaItems = new ArrayList<MediaItem>(results.size());
for (String json : results) {
mediaItems.add(ItemFactory.createMediaItem(json));
}
return mediaItems;
}
开发者ID:socialsensor,项目名称:socialsensor-framework-client,代码行数:17,代码来源:MediaItemDAOImpl.java
示例11: getMediaItemsForItems
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
@Override
public List<MediaItem> getMediaItemsForItems(List<String> itemIds, String mediaType, int size) {
String fieldName = "type";
String fieldValue = mediaType;
String orField = "reference";
List<String> values = itemIds;
List<String> results = mongoHandler.findManyWithOr(fieldName, fieldValue, orField, values, size);
List<MediaItem> mediaItems = new ArrayList<MediaItem>(results.size());
for (String json : results) {
mediaItems.add(ItemFactory.createMediaItem(json));
}
return mediaItems;
}
开发者ID:socialsensor,项目名称:socialsensor-framework-client,代码行数:17,代码来源:MediaItemDAOImpl.java
示例12: getMediaItemsForUrls
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
@Override
public List<MediaItem> getMediaItemsForUrls(List<String> urls, String mediaType, int size) {
String fieldName = "type";
String fieldValue = mediaType;
String orField = "refUrl";
List<String> values = urls;
List<String> results = mongoHandler.findManyWithOr(fieldName, fieldValue, orField, values, size);
List<MediaItem> mediaItems = new ArrayList<MediaItem>(results.size());
Set<String> uniqueUrls = new HashSet<String>();
for (String json : results) {
MediaItem mediaItem = ItemFactory.createMediaItem(json);
if (!uniqueUrls.contains(mediaItem.getUrl())) {
uniqueUrls.add(mediaItem.getUrl());
mediaItems.add(mediaItem);
}
}
return mediaItems;
}
开发者ID:socialsensor,项目名称:socialsensor-framework-client,代码行数:22,代码来源:MediaItemDAOImpl.java
示例13: getMediaItemsByUrls
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
@Override
public List<MediaItem> getMediaItemsByUrls(List<String> urls,
String mediaType, int size) {
String fieldName = "type";
String fieldValue = mediaType;
String orField = "url";
List<String> values = urls;
List<String> results = mongoHandler.findManyWithOr(fieldName, fieldValue, orField, values, size);
List<MediaItem> mediaItems = new ArrayList<MediaItem>(results.size());
Set<String> uniqueUrls = new HashSet<String>();
for (String json : results) {
MediaItem mediaItem = ItemFactory.createMediaItem(json);
if (!uniqueUrls.contains(mediaItem.getUrl())) {
uniqueUrls.add(mediaItem.getUrl());
mediaItems.add(mediaItem);
}
}
return mediaItems;
}
开发者ID:socialsensor,项目名称:socialsensor-framework-client,代码行数:23,代码来源:MediaItemDAOImpl.java
示例14: getUnindexedItems
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
@Override
public List<MediaItem> getUnindexedItems(int max) {
Selector query = new Selector();
query.select("indexed", Boolean.FALSE);
List<String> jsonMediaItems = mongoHandler.findManyNoSorting(query, max);
List<MediaItem> mediaItems = new ArrayList<MediaItem>();
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.create();
for (String json : jsonMediaItems) {
MediaItem mediaItem = gson.fromJson(json, MediaItem.class);
mediaItems.add(mediaItem);
}
return mediaItems;
}
开发者ID:socialsensor,项目名称:socialsensor-framework-client,代码行数:20,代码来源:MediaItemDAOImpl.java
示例15: insertMediaItem
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
@SuppressWarnings("finally")
public boolean insertMediaItem(MediaItem item) {
boolean status = true;
try {
SolrMediaItem solrItem = new SolrMediaItem(item);
server.addBean(solrItem, commitPeriod);
//UpdateResponse response = server.commit();
//int statusId = response.getStatus();
//if (statusId == 0) {
// status = true;
//}
} catch (Exception ex) {
ex.printStackTrace();
Logger.getRootLogger().error(ex.getMessage());
status = false;
} finally {
return status;
}
}
开发者ID:socialsensor,项目名称:socialsensor-framework-client,代码行数:25,代码来源:SolrMediaItemHandler.java
示例16: importFromFiles
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
private void importFromFiles() throws Exception {
RevealMediaItemDaoImpl mediaDao = new RevealMediaItemDaoImpl("160.40.51.20", "Showcase", "MediaItems");
BufferedReader reader;
String jsonFilesFolder = "/home/kandreadou/Pictures/snow/";
JsonParser parser = new JsonParser();
List<String> jsonFiles = new ArrayList<String>();
for (int i = 0; i < 42; i++) {
jsonFiles.add(jsonFilesFolder + "tweets.json." + i);
}
for (int i = 30; i < jsonFiles.size(); i++) {
System.out.println(jsonFiles.get(i));
reader = new BufferedReader(new InputStreamReader(
new FileInputStream(jsonFiles.get(i)), "UTF-8"));
String line = null;
while ((line = reader.readLine()) != null) {
JsonObject tweet = parser.parse(line).getAsJsonObject();
String tweetId = tweet.get("id").getAsString();
MediaItem item = mediaDao.getMediaItem(tweetId);
if (item != null) {
System.out.println(item);
if (StringUtils.isEmpty(item.getDescription())) {
String text = tweet.get("text").getAsString();
System.out.println(text);
item.setDescription(text);
}
if (item.getPublicationTime() == 0) {
String created_at = tweet.get("created_at").getAsString();
System.out.println(created_at);
item.setPublicationTime(DateUtil.parseDate(created_at).getTime());
}
mediaDao.updateMediaItem(item);
}
}
reader.close();
}
}
开发者ID:kandreadou,项目名称:reveal-web-service,代码行数:38,代码来源:TextImporter.java
示例17: run
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
public void run() {
while(true) {
Pair<?, ?> obj = _tupleQueue.poll();
if(obj != null) {
synchronized(_collector) {
if(MediaItem.class.isInstance(obj.getLeft())) {
mediaTuples++;
_collector.emit(MEDIA_STREAM,
tuple(obj.getLeft(), obj.getRight()));
}
else if(WebPage.class.isInstance(obj.getLeft())) {
webPagesTuples++;
_collector.emit(WEBPAGE_STREAM, tuple(obj.getLeft(), obj.getRight()));
}
}
}
else {
Utils.sleep(500);
}
if((mediaTuples%100==0 || webPagesTuples%100==0) && (mediaTuples!=0 || webPagesTuples!=0)) {
_logger.info(receivedTuples + " tuples received, " + mediaTuples + " media tuples emmited, " +
webPagesTuples + " web page tuples emmited");
_logger.info(getWorkingFetchers() + " fetchers out of " + numOfFetchers + " are working.");
}
}
}
开发者ID:socialsensor,项目名称:storm-focused-crawler,代码行数:28,代码来源:FetcherBolt.java
示例18: execute
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
public void execute(Tuple input) {
try {
MediaItem mi = (MediaItem) input.getValueByField("MediaItem");
if(mi != null) {
publisherJedis.publish(channel, mi.getId());
}
}
catch(Exception e) {
logger.error(e);
}
}
开发者ID:socialsensor,项目名称:storm-focused-crawler,代码行数:12,代码来源:RedisBolt.java
示例19: execute
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
public void execute(Tuple input) {
try {
String json = input.getStringByField(inputField);
MediaItem mediaItem = ItemFactory.createMediaItem(json);
if(mediaItem != null) {
_collector.emit(tuple(mediaItem));
}
} catch(Exception e) {
_logger.error("Exception: "+e.getMessage());
}
}
开发者ID:socialsensor,项目名称:storm-focused-crawler,代码行数:12,代码来源:MediaItemDeserializationBolt.java
示例20: FlickrItem
import eu.socialsensor.framework.common.domain.MediaItem; //导入依赖的package包/类
public FlickrItem(Photo photo, StreamUser streamUser) {
this(photo);
//User that posted the photo
this.streamUser = streamUser;
uid = streamUser.getId();
for(MediaItem mItem : mediaItems) {
mItem.setUserId(uid);
}
}
开发者ID:socialsensor,项目名称:socialmedia-abstractions,代码行数:13,代码来源:FlickrItem.java
注:本文中的eu.socialsensor.framework.common.domain.MediaItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论