Examples of AlchemyClassification


Examples of uk.ac.cam.ha293.tweetlabel.classify.AlchemyClassification

    Map<String,Double> urlCategoryScores = new HashMap<String,Double>();
    Map<String,Integer> urlCategoryCounts = new HashMap<String,Integer>();
   
    for(SimpleTweet tweet : tweets) {
      //Handle tweet content classification
      AlchemyClassification textClassification = AlchemyClassifier.classifyText(tweet.getText());
      if(textClassification == null) {
        System.err.println("Daily Transaction Limit has been reached (or a null classification was given weirdly)");
        return false;
      }
     
      writeOutTweets.print(tweet.getTweetID()+","+textClassification.getCategory()+","+textClassification.getScore());
      System.err.println("JUST WROTE TWEEET OUT");
     
      if(textCategoryScores.containsKey(textClassification.getCategory())) {
        //Add the new value, since the key already exists
        textCategoryScores.put(textClassification.getCategory(), textCategoryScores.get(textClassification.getCategory()) + textClassification.getScore());
        textCategoryCounts.put(textClassification.getCategory(), textCategoryCounts.get(textClassification.getCategory()) + 1);
      } else {
        //Insert the category into the map
        textCategoryScores.put(textClassification.getCategory(), textClassification.getScore());
        textCategoryCounts.put(textClassification.getCategory(), 1);
      }
     
      //Handle URL classification
      for(String url : tweet.getUrls()) {
        AlchemyClassification urlClassification = AlchemyClassifier.classifyURL(url);
        if(urlClassification == null) {
          System.err.println("Daily Transaction Limit has been reached (or a null classification was given weirdly)");
          return false;
        }
       
        writeOutTweets.print(","+urlClassification.getCategory()+","+urlClassification.getScore());
       
        if(urlCategoryScores.containsKey(urlClassification.getCategory())) {
          //Add the new value, since the key already exists
          urlCategoryScores.put(urlClassification.getCategory(), urlCategoryScores.get(urlClassification.getCategory()) + urlClassification.getScore());
          urlCategoryCounts.put(urlClassification.getCategory(), urlCategoryCounts.get(urlClassification.getCategory()) + 1);
        } else {
          //Insert the category into the map
          urlCategoryScores.put(urlClassification.getCategory(), urlClassification.getScore());
          urlCategoryCounts.put(urlClassification.getCategory(), 1);
        }
      }

      //writeOutTweets.println();
    }
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.classify.AlchemyClassification

        if(count < startFromHere) {count++;continue;}
        String[] split = nextLine.split("\t");
        long uid = Long.parseLong(split[0]);
        BigInteger tid = new BigInteger(split[1]);
        String tweet = split[2];
        AlchemyClassification c = AlchemyClassifier.classifyText(tweet);
        while(c == null) {
          c = AlchemyClassifier.classifyText(tweet);
         
        }
        System.out.println(count+"\t"+uid+"\t"+tid+"\t"+c.getCategory()+"\t"+c.getScore());
        //writeOut += uid+"\t"+tid+"\t"+c.getCategory()+"\t"+c.getScore()+"\n";
        count++;
      }
      //write.print(writeOut);
      //write.close();
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.