Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By Junky

Thread: Need help - Most commonly used words on facebook script

  1. #1
    shoffing is offline Member
    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    Angry 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.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    The majority of people are not going to follow a link and download your code. Provide a SSCCE instead.
    shoffing likes this.

Similar Threads

  1. Facebook
    By sunde887 in forum Suggestions & Feedback
    Replies: 0
    Last Post: 04-30-2011, 10:27 AM
  2. facebook-like framework
    By robertgrzeda in forum Web Frameworks
    Replies: 0
    Last Post: 04-16-2010, 12:48 PM
  3. Commonly used packages
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-17-2007, 10:05 AM
  4. help w words
    By Gilgamesh in forum New To Java
    Replies: 5
    Last Post: 11-21-2007, 06:15 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •