当前位置: 首页>>代码示例>>Java>>正文


Java Item类代码示例

本文整理汇总了Java中eu.socialsensor.framework.common.domain.Item的典型用法代码示例。如果您正苦于以下问题:Java Item类的具体用法?Java Item怎么用?Java Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Item类属于eu.socialsensor.framework.common.domain包,在下文中一共展示了Item类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findPopularTitleCERTH_old

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
public static String findPopularTitleCERTH_old(Dysco dysco){
        List<Item> items=dysco.getItems();
        List<String> textItems=new ArrayList<String>();
        Set<String> entities=new HashSet<String>();
        List<Entity> ents=dysco.getEntities();
        for(Entity ent:ents)
            entities.add(ent.getName());
//        Logger.getRootLogger().info("Title extractor (case 3): Getting candidate sentences");
        for(Item item_tmp:items){
            List<String> sentences=getSentences1_old(item_tmp.getTitle(),entities);
            textItems.addAll(sentences);
        }
            
//        Logger.getRootLogger().info("Title extractor (case 3): Finding most popular sentence");
        String title=findPopularTitleNew(textItems);
        if(((title==null)||(title.trim().length()==0))&&(textItems.size()>0))
            title=extractor.cleanText(textItems.get(0));       
        if(((title==null)||(title.trim().length()==0))&&(textItems.size()>0))
            title=textItems.get(0);
        if(((title==null)||(title.trim().length()==0))&&(items.size()>0))
            title=items.get(0).getTitle();
        return title.replaceAll("\\s{2,}", " ");
        
    }
 
开发者ID:socialsensor,项目名称:trends-labeler,代码行数:25,代码来源:TrendsLabeler.java

示例2: execute

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
public void execute(Tuple input) {
	try {
		Item item = (Item)input.getValueByField("Item");
		if(item == null)
			return;
		
		String title = item.getTitle();
		if(title != null) {
			List<Entity> entities = extract(title);
			item.setEntities(entities);
		}
		_collector.emit(new Values(item));
	}
	catch(Exception e) {
		_logger.error(e);
	}
}
 
开发者ID:socialsensor,项目名称:storm-focused-crawler,代码行数:18,代码来源:EntityExtractionBolt.java

示例3: prepare

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
public void prepare(@SuppressWarnings("rawtypes") Map conf, TopologyContext context, 
		OutputCollector collector) {
	_logger = Logger.getLogger(ItemIndexerBolt.class);
	
	queue = new ArrayBlockingQueue<Item>(5000);
	try {
		_solrItemHandler = SolrItemHandler.getInstance(_service);
	} catch (Exception e) {
		e.printStackTrace();
		_solrItemHandler = null;
		_logger.error(e);
	}
	
	Thread t = new Thread(new TextIndexer());
	t.start();
}
 
开发者ID:socialsensor,项目名称:storm-focused-crawler,代码行数:17,代码来源:ItemIndexerBolt.java

示例4: loadItemsFromFilePlain

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
public static List<Item> loadItemsFromFilePlain(String filename){
    List<Item> items=new ArrayList<Item>();
    try{
        BufferedReader br=new BufferedReader(new FileReader(filename));
        String line=null;
        int i=0;
        while((line=br.readLine())!=null){
            i=i+1;
            if(line.trim()!=""){
                Item new_item=new Item();
                String[] parts=line.split("%%%");
                new_item.setId(parts[0]);
                new_item.setTitle(parts[1].replaceAll("\"",""));
                items.add(new_item);
            }
        }
        br.close();
    }
    catch(Exception ex){
        ex.printStackTrace();
    }
    return items;
}
 
开发者ID:socialsensor,项目名称:topic-detection,代码行数:24,代码来源:Tester.java

示例5: run

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
@Override
public void run() {
	while(true) {
		List<Item> items = itemDAO.getLatestItems(10000);
		System.out.println("Last items: " + items.size());
		
		List<Dysco> dyscos = dyscoCreator.createDyscos(items);
		System.out.println("Total dyscos found: " + dyscos.size());
		for(Dysco dysco : dyscos) {
			System.out.println("Items of dysco " + dysco.getId() + " " +  
					dysco.getItems().size());
		}
		
		return;
	}
	
}
 
开发者ID:socialsensor,项目名称:socialsensor-multimedia-analysis,代码行数:18,代码来源:MultimediaDyscoCreation.java

示例6: loadItemsFromFile

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
public static List<Item> loadItemsFromFile(String filename){
    List<Item> items=new ArrayList<Item>();
    try{
        BufferedReader br=new BufferedReader(new FileReader(filename));
        String line=null;
        while((line=br.readLine())!=null){
            if(line.trim()!=""){
                Item new_item=new Item();
                DBObject dbObject = (DBObject) JSON.parse(line);
                String id=(String) dbObject.get("id_str");
                new_item.setId(id);
                String text=(String) dbObject.get("text");
                new_item.setTitle(text);
                DBObject tmp_obj=(DBObject) dbObject.get("user");
                String uploader=(String) tmp_obj.get("screen_name");
                new_item.setAuthorScreenName(uploader);
                items.add(new_item);
            }
        }
        br.close();
    }
    catch(Exception ex){
        ex.printStackTrace();
    }
    return items;
}
 
开发者ID:socialsensor,项目名称:topic-detection,代码行数:27,代码来源:Tester.java

示例7: main

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
/**
 * Tester for the LDA class
 * @param args no args required
 * @throws Exception
 */
public static void main(String[] args) throws Exception
{
	System.out.println("Reading input");
	BufferedReader reader = new BufferedReader(new FileReader("./resources/docs-test"));
	String line = reader.readLine();
	ArrayList<Item> documents = new ArrayList<Item>();
	while (line!=null)
	{
		Item item = new Item();
		item.setText(line);
		line = reader.readLine();
		documents.add(item);
	}
	reader.close();
	
	System.out.println("Computing LDA");
	LDA lda = new LDA();
	List<LDATopic> topics = lda.run(documents,10,10,10);
	for (LDATopic t : topics)
	{
		System.out.println(t);
	}
	System.out.println("Done!");
}
 
开发者ID:socialsensor,项目名称:topic-detection,代码行数:30,代码来源:TestLDA.java

示例8: createDyscos

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
public List<Dysco> createDyscos(List<Item> items) {
    Map<String,Item> items_map=new HashMap<String,Item>();
    for(int i=0;i<items.size();i++)
        items_map.put(items.get(i).getId(),items.get(i));
    Vocabulary vocabulary_corpus=Vocabulary.getCorpusVocabulary(items.iterator(),true);
    vocabulary_corpus.filterByNoOfOccurrences(2);
    Vocabulary vocabulary_reference=new Vocabulary();
    vocabulary_reference.load(true);
    System.out.println("Read reference vocabulary");
    VocabularyComparator vocabulary_comparator=new VocabularyComparator(vocabulary_corpus,vocabulary_reference);
    vocabulary_comparator.outputOrdered(vocabulary_comparator.vocabulary_new_corpus.directory+vocabulary_comparator.vocabulary_new_corpus.filename_start+".vocabulary_ratios");
    System.out.println("Getting topics");
    List<Dysco> dyscos=vocabulary_comparator.getDyscosBySFIM(items_map);
    List<Dysco> finalDyscos=new ArrayList<Dysco>();
    for(Dysco dysco:dyscos){
        if(dysco.getKeywords().size()<10)
            finalDyscos.add(dysco);
    }
    return finalDyscos;
}
 
开发者ID:socialsensor,项目名称:topic-detection,代码行数:21,代码来源:DyscoCreator.java

示例9: getCorpusVocabulary

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
public static Vocabulary getCorpusVocabulary(Iterator<Item> postIterator,boolean keepTweetIDs){
       Vocabulary vocabulary=new Vocabulary();
       Item tmp_post;
//        while((tmp_tweet=getNextTweetFromFile())!=null){
       Iterator<String> it;
        while(postIterator.hasNext()){
            tmp_post=postIterator.next();
            List<String> tmp_tokens=TweetPreprocessor.Tokenize(tmp_post.getTitle());
//            List<String> tmp_tokens=tmp_post.getTokens();
            String tmp_term;
            it = tmp_tokens.iterator();
            while (it.hasNext()) {
                tmp_term=(String) it.next();
                if(keepTweetIDs)
                    vocabulary.increaseTermFrequency(tmp_term,tmp_post.getId());
                else
                    vocabulary.increaseTermFrequency(tmp_term);
            }
        }
        return vocabulary;
    }
 
开发者ID:socialsensor,项目名称:topic-detection,代码行数:22,代码来源:Vocabulary.java

示例10: getItemsSince

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
@Override
public List<Item> getItemsSince(long date) {
    Selector query = new Selector();
    query.selectGreaterThan("publicationTime", date);
    long l = System.currentTimeMillis();
    List<String> jsonItems = mongoHandler.findMany(query, 0);
    l = System.currentTimeMillis() - l;
    System.out.println("Fetch time: " + l + " msecs");
    l = System.currentTimeMillis() - l;

    List<Item> results = new ArrayList<Item>();
    for (String json : jsonItems) {
        results.add(ItemFactory.create(json));
    }
    l = System.currentTimeMillis() - l;
    System.out.println("List time: " + l + " msecs");
    return results;
}
 
开发者ID:socialsensor,项目名称:socialsensor-framework-client,代码行数:19,代码来源:ItemDAOImpl.java

示例11: getUnindexedItems

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
@Override
public List<Item> getUnindexedItems(int max) {
    Selector query = new Selector();
    query.select("indexed", Boolean.FALSE);
    query.select("original", Boolean.TRUE);

    List<String> jsonItems = mongoHandler.findManyNoSorting(query, max);
    List<Item> items = new ArrayList<Item>();
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .create();

    for (String json : jsonItems) {
        Item item = gson.fromJson(json, Item.class);

        items.add(item);
    }

    return items;
}
 
开发者ID:socialsensor,项目名称:socialsensor-framework-client,代码行数:21,代码来源:ItemDAOImpl.java

示例12: readItemsByStatus

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
@Override
public List<Item> readItemsByStatus() {
    Selector query = new Selector();
    query.select("isSearched", Boolean.FALSE);
    List<String> jsonItems = mongoHandler.findMany(query, -1);
    List<Item> items = new ArrayList<Item>();
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .create();

    for (String json : jsonItems) {
        Item item = gson.fromJson(json, Item.class);

        items.add(item);
    }

    return items;
}
 
开发者ID:socialsensor,项目名称:socialsensor-framework-client,代码行数:19,代码来源:ItemDAOImpl.java

示例13: getUniqueTerms

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
public static List<RankedTitleRGU>getTweetScores(Dysco dysco) {
	
	List<Item> items = dysco.getItems();
	List<String> allText = new ArrayList<String>(items.size());
               HashMap<String, Item> itemsMap=new HashMap<String,Item>();
	for (Item item : items) {
		allText.add(item.getTitle());
                       itemsMap.put(item.getTitle(), item);
	}
	HashMap<String, Integer> uniqueTexts = new HashMap<String, Integer>();
	for (String text : allText) {
		Integer count = uniqueTexts.get(text);
		if (count == null)
			uniqueTexts.put(text, 1);
		else
			uniqueTexts.put(text, count + 1);
	}

	HashMap<String, Integer> uniqueTerms = getUniqueTerms(dysco); //combine keywords, entities, hashtags

	// other parameters
	int numberOfTopicTerms = uniqueTerms.size();
	double a = 0.8;
	int numberOfTweets = dysco.getItems().size();

	//variable to fill in 
	List<RankedTitleRGU> tweetScores = new ArrayList<RankedTitleRGU>(numberOfTweets);
	
	for (String title : allText){
		RankedTitleRGU rankedTitle = new RankedTitleRGU(title,itemsMap.get(title));
		int numberOfDuplicatesLikeCurrentTweet = uniqueTexts.get(title);
		int numberOfTermsContainedInTweet = calculateNumberOfTermsContainedInTweet(uniqueTerms, title);
		rankedTitle.calculateScore(a, numberOfTermsContainedInTweet, numberOfTopicTerms, numberOfDuplicatesLikeCurrentTweet, numberOfTweets);
		tweetScores.add(rankedTitle);
	}

	return tweetScores;

}
 
开发者ID:socialsensor,项目名称:trends-labeler,代码行数:40,代码来源:TrendsLabeler.java

示例14: getTerms

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
public Set<String> getTerms(Item item){
        String tmp_item_text=item.getTitle();
        Set<String> tmp_urls=getURLs(tmp_item_text);
        Iterator it = tmp_urls.iterator();
        while (it.hasNext()) {
            String next_url=(String) it.next();
            tmp_item_text=tmp_item_text.replaceAll(next_url, "");
        }

        Set<String> tmp_set=new HashSet<String>();
        Scanner tokenize;
        String tmp_word;
        if(tmp_item_text!=null){
            tokenize = new Scanner(tmp_item_text);
            //Punctuation and white space is used for 
            //splitting the text in tokens.
            tokenize.useDelimiter(delimiters);
            while (tokenize.hasNext()) {
                tmp_word=tokenize.next().toLowerCase();
                tmp_word.replaceAll(delimiters, "");
                //The following lines try to remove punctuation.
                //Maybe it should be skipped or revised
                String[] tmp_str=tmp_word.split(punctuation);
                while((tmp_word.length()>0)&&((tmp_word.charAt(0)+"").matches(punctuation)))
                    tmp_word=tmp_word.substring(1);
                while((tmp_word.length()>0)&&((tmp_word.charAt(tmp_word.length()-1)+"").matches(punctuation)))
                    tmp_word=tmp_word.substring(0,tmp_word.length()-1);
                if(!isUserMention(tmp_word)){
    //                if((!StopWords.IsStopWord(tmp_word))&&(tmp_word.length()>=Constants.MIN_WORD_LENGTH))
                    if((tmp_word.length()>=3))
                        tmp_set.add(tmp_word);
                }
//                else if(Constants.TWEET_REMOVE_USER_MENTIONS==false)
//                    tmp_set.add(tmp_word);
            }
        }
        return tmp_set;
    }
 
开发者ID:socialsensor,项目名称:topic-detection,代码行数:39,代码来源:DyscoCreator.java

示例15: execute

import eu.socialsensor.framework.common.domain.Item; //导入依赖的package包/类
public void execute(Tuple input) {
	try {
		String json = input.getStringByField(inputField);
		if(json != null) {
			Item item = ItemFactory.create(json);
			_collector.emit(tuple(item));
		}
	} catch(Exception e) {
		_logger.error("Exception: "+e.getMessage());
	}
}
 
开发者ID:socialsensor,项目名称:storm-focused-crawler,代码行数:12,代码来源:ItemDeserializationBolt.java


注:本文中的eu.socialsensor.framework.common.domain.Item类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。