Examples of CategoryScore


Examples of uk.ac.cam.ha293.tweetlabel.types.CategoryScore

 
  public List<CategoryScore> logClassify(String document) {
    List<CategoryScore> categoryScores = new ArrayList<CategoryScore>();
    for(Category category : categories.keySet()) {
      double logP = logPOfCategoryGivenDocument(category, Tools.LIWCStripTweet(document));
      categoryScores.add(new CategoryScore(category,logP));     
    }
    return categoryScores;
  }
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.types.CategoryScore

 
  public List<CategoryScore> classify(String document) {
    List<CategoryScore> categoryScores = new ArrayList<CategoryScore>();
    for(Category category : categories.keySet()) {
      double p = pOfCategoryGivenDocument(category, Tools.LIWCStripTweet(document));
      categoryScores.add(new CategoryScore(category,p));     
    }
    return categoryScores;
 
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.types.CategoryScore

    while(it.hasNext()) {   
      Category cat = it.next();
      if(categoryBlacklistSet.contains(cat.getTitle())) continue; //Don't include blacklist categories
      if(categoryScores.get(cat) == 0) continue; //Remove zero scoring categories
      //System.out.println(cat.getTitle()+": "+categoryScores.get(cat));
      results.add(new CategoryScore(cat,categoryScores.get(cat)));
    }
   
    return results;
  }
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.types.CategoryScore

  public List<CategoryScore> classifyTweetNaiveBayes(SimpleTweet tweet) { 
    String text = Tools.LIWCStripTweet(tweet.getText());
    List<CategoryScore> results = naiveBayes.logClassify(text);
    //List<CategoryScore> results = naiveBayes.classify(text);
    for(Iterator<CategoryScore> it = results.iterator(); it.hasNext();) {
      CategoryScore score = it.next();
      if(categoryBlacklistSet.contains(score.getCategory().getTitle())) it.remove(); //Don't include blacklist categories
    }
    Collections.sort(results);
    Collections.reverse(results);
    return results;
  }
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.types.CategoryScore

    //print results
    while(it.hasNext()) {   
      Category cat = it.next();
      //System.out.println(cat.getTitle()+": "+categoryScores.get(cat));
      if(categoryBlacklistSet.contains(cat.getTitle())) continue; //Don't include blacklist categories
      results.add(new CategoryScore(cat,categoryScores.get(cat)));
    }
   
    return results;
  }
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.types.CategoryScore

      String text = Tools.LIWCStripTweet(tweet.getText());
      List<CategoryScore> scores = naiveBayes.logClassify(text);
      //List<CategoryScore> scores = naiveBayes.classify(text);

      for(Iterator<CategoryScore> it = scores.iterator(); it.hasNext();) {
        CategoryScore next = it.next();
       
        //Moving average calculation
        if(averageScores.containsKey(next.getCategory())) {
          averageScores.put(next.getCategory(), (((averageScores.get(next.getCategory())*averageCount)+next.getScore())/(averageCount+1)));
        } else {
          averageScores.put(next.getCategory(), next.getScore());
        }
       
        //System.out.println(next.getCategory().getTitle()+": new logP="+next.getLIWCLogP()+", new avg="+averageScores.get(next.getCategory()));
      }
      averageCount++;
    }
   
    List<CategoryScore> results = new ArrayList<CategoryScore>();
    for(Category category : averageScores.keySet()) {
      if(categoryBlacklistSet.contains(category.getTitle())) continue; //Don't include blacklist categories
      results.add(new CategoryScore(category,averageScores.get(category)));
    }
    Collections.sort(results);
    Collections.reverse(results);
   
    return results;
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.types.CategoryScore

        if(nextLine == null) break;
        String[] splitTweet = nextLine.split(",");
        long tweetID = Long.parseLong(splitTweet[0]);
        List<CategoryScore> categoryScores = new ArrayList<CategoryScore>();
        for(int i=1;i<splitTweet.length; i+=2) {
          CategoryScore categoryScore = new CategoryScore(stringCategoryLookup.get(splitTweet[i]),Double.parseDouble(splitTweet[i+1]));
          categoryScores.add(categoryScore);
        }
        tweetScores.put(tweetID, categoryScores);
      }
    } catch (IOException e){
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.types.CategoryScore

        if(nextLine == null) break;
        String[] splitTweet = nextLine.split(",");
        long tweetID = Long.parseLong(splitTweet[0]);
        List<CategoryScore> categoryScores = new ArrayList<CategoryScore>();
        for(int i=1;i<splitTweet.length; i+=2) {
          CategoryScore categoryScore = new CategoryScore(stringCategoryLookup.get(splitTweet[i]),Double.parseDouble(splitTweet[i+1]));
          categoryScores.add(categoryScore);
        }
        tweetScores.put(tweetID, categoryScores);
      }
    } catch (IOException e){
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.