Results 1 to 2 of 2
- 06-01-2011, 03:43 AM #1
Member
- Join Date
- Jun 2011
- Posts
- 1
- Rep Power
- 0
Need help - Most commonly used words on facebook script
I'm attempting to make something that reads from your facebook friends' statuses and finds the most frequently used words. The problem I'm having is extremely elusive, I have no idea why it's not working. It would return statuses like "i think i need the yonana maker" and not recognize that there are 2 identical words in there. Please help, I've wasted 3 hours now on something that I thought would be the most trivial thing I've ever done.
friends, words, and wordsCount are ArrayList<String>'s.
The problem is that it's not "FINDING A FUCKING MATCH", pardon my language.
If someone can help me with the regex expression that I can use to replace all those .replace statements, it would be very helpful indeed. I basically just want to get rid of the gibberish and keep the letters.
Java Code:for (int i = 0; i < friends.size(); i++) { String name = friends.get(i).split(",")[0]; String id = friends.get(i).split(",")[1]; System.out.println("-----------"); System.out.println(name); System.out.println("-----------"); String currentPage = "https://graph.facebook.com/" + id + "/statuses" + token; String page = readFromURL(currentPage); String[] pageMessages = page.split("message"); for (int j = 1; j < pageMessages.length; j++) { String cutMsg = pageMessages[j].split("\",\"")[0].substring(3); cutMsg = cutMsg.replace("~", " ").replace(".", " ").replace("!", " ").replace("?", " ").replace("/", " ").replace("\\", " ").replace(",", " ").replace("@", " ").replace("#", " ").replace("$", " ").replace("%", " ").replace("^", " ").replace("&", " ").replace("*", " ").replace("(", " ").replace(")", " ").replace("'", " ").replace("\\n", " ").replace("-", " ").replace(":", " ").replace("\"", " ").toLowerCase(); System.out.println(cutMsg); String[] tw = cutMsg.split(" "); System.out.println(tw); for (int k = 0; k < tw.length; k++) { if (tw[k] != "" && !(tw[k].startsWith("u0"))) { tw[k] = tw[k].replace(" ", ""); boolean found = false; for (int m = 0; m < words.size(); m++) { //System.out.println("======"); //System.out.println(words.get(m) + "," + tw[k]); if (tw[k] == words.get(m)) { wordsCount.set(m, "" + (Integer.parseInt(wordsCount.get(m)) + 1)); System.out.println("FOUND A FUCKING MATCH!" + tw[k]); found = true; bubbleSort(words, wordsCount); break; } try { Thread.sleep(5); } catch(Exception e) { } } if (!found) { words.add(tw[k]); wordsCount.add("1"); } } } } } }
Full code, if you can't see the problem here:
http://pastebin.com/ZVWzWEC6


Last edited by shoffing; 06-01-2011 at 03:53 AM.
- 06-01-2011, 03:46 AM #2
Similar Threads
-
Facebook
By sunde887 in forum Suggestions & FeedbackReplies: 0Last Post: 04-30-2011, 10:27 AM -
facebook-like framework
By robertgrzeda in forum Web FrameworksReplies: 0Last Post: 04-16-2010, 12:48 PM -
Commonly used packages
By Java Tip in forum Java TipReplies: 0Last Post: 12-17-2007, 10:05 AM -
help w words
By Gilgamesh in forum New To JavaReplies: 5Last Post: 11-21-2007, 06:15 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks