/** * Note the tweets with the chosen method * * @param listeTweets : list of tweets * @param algo : choice of the ranking method * @throws IOException */ public void rateTweets(List<Tweet> listeTweets, String algo) throws IOException { for (Tweet tweet : listCleanTweets) { String text = tweet.getTweet(); int mark = 0; switch (algo) { case "Keyword": mark = KeywordMethod.getClassePosNeg(text); break; case "Knn": mark = KnnMethod.knn(text, 30, baseTweets); break; case "BayesUniPres": mark = BayesMethod.rankBayes(listCleanTweets, text, 0); break; case "BayesUniFreq": mark = BayesMethod.rankBayes(listCleanTweets, text, 1); break; case "BayesBigPres": mark = BayesBiGrammeMethod.rankBigramBayes(listCleanTweets, text, 1); break; case "BayesBigFreq": mark = BayesBiGrammeMethod.rankBigramBayes(listCleanTweets, text, 0); break; } tweet.setNote(mark); } }
/** Adds the seached tweets to the file tweetsBase.csv */ public void saveBase() { try { if (baseTweets == null) { baseTweets = new ArrayList<Tweet>(); } CsvWriter csvOutput = new CsvWriter(new FileWriter(AppliSettings.filename, true), ';'); for (Tweet tweet : listCleanTweets) { int index = alreadyIn(tweet.getId()); if (index == -1) { csvOutput.write("" + tweet.getId()); csvOutput.write(tweet.getUser()); String text = cleanTweet(tweet.getTweet()); csvOutput.write(text); csvOutput.write("" + tweet.getDate()); csvOutput.write("" + tweet.getNote()); csvOutput.endRecord(); baseTweets.add(tweet); } else { updateCSV(tweet.getNote(), index); } } csvOutput.close(); } catch (IOException e) { System.out.println("saveBase"); System.out.println(e.getMessage()); } }
public static void clean(Tweet tw) { String tweet = removeUrl(tw.getTweet()); List<String> newToks = Twokenize.tokenizeRawTweetText(tweet); replaceSlangs(newToks); // newToks = removeStopWords(newToks); tweet = String.join(" ", newToks); tw.setTweet(tweet); }
@Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.tweet_row, null); } Tweet tweet = tweets.get(position); if (tweet != null) { TextView tweetText = (TextView) v.findViewById(R.id.tweetTxt); if (tweetText != null) { tweetText.setText("Tweet: " + tweet.getTweet()); } } return v; }