Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package problema;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.Arrays;
- public class TweetAnalysis {
- public static int countTags = 0;
- public static String initDateTime = "2014-07-06T18:08:22";
- public static String endDateTime = "2014-07-06T18:08:24";
- public static String fileToRead;
- public static String tagFile = "C:/Users/Rebelo/Desktop/Eclipse/problema/AED/hastag.tag";
- public static void main(String[] args) throws IOException {
- fileToRead = "C:/Users/Rebelo/Desktop/Eclipse/problema/AED/sample44Xfiltered.twt/sample44Xfiltered.twt";
- moreMentioned(initDateTime, endDateTime, tagFile);
- }
- public static String[] readTagFile(String file) throws IOException {
- String tagsFromFile = "";
- String[] tags;
- String line;
- BufferedReader reader = new BufferedReader(new FileReader(file));
- while ((line = reader.readLine()) != null) {
- tagsFromFile += line + " ";
- ++countTags;
- }
- reader.close();
- tags = tagsFromFile.split(" ");
- return tags;
- }
- public static String moreMentioned(String initDateTime, String endDateTime, String file) throws IOException {
- int moreMentioned = 0;
- String line, split;
- String[] tags = readTagFile(file);
- Long currDate, initTime = ConvertDate.getInstant(initDateTime), endTime = ConvertDate.getInstant(endDateTime);
- String[] hashtags;
- BufferedReader reader = new BufferedReader(new FileReader(fileToRead));
- while ((line = reader.readLine()) != null) {
- currDate = ConvertDate.getInstant(line.substring(line.indexOf(":") + 3, line.indexOf(",") - 1));
- if (currDate >= initTime && currDate <= endTime) {
- split = line.substring(line.indexOf("[") + 1, line.indexOf("]"));
- hashtags = split.split(", ");
- }
- }
- reader.close();
- return tags[moreMentioned];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement