File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Need help to count emoticons from a Twitter search API? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need help to count emoticons from a Twitter search API?" Watch "Need help to count emoticons from a Twitter search API?" New topic
Author

Need help to count emoticons from a Twitter search API?

Rupinder Sandhu
Greenhorn

Joined: Mar 13, 2013
Posts: 3
Hey

I have code that allows me to get data from a Twitter Search API. However I am having trouble counting the emoticons. I have a text file, with 126 emoticons, that I have classified against numbers 1-6. These numbers represent emotions. So one column is emoticons and next to it is the corresponding number.
How do I read the text file that has both emoticon and number, and search the API and count the emoticons that it catches.
So for example

1
1 =)
1 :-)

2 :@
2 >

3
3 :-(

etc. That is how the text file is set up.

So every time an emoticon is caught in the search API, I want the count for each number to increase. How do I go about doing that? I have looked all over the web, which is how I noticed this forum.




I have tried that, but I have to input a pattern. And it gives me a count, but not one that is correct, because I checked manually.


Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Welcome to the Ranch

Why are you using the + operator with chars? Do you realise that chars are not letters, but numbers? So your + will not give you the String at all? You can still use ==, but it will not give you the result you want.

I think you need to go back to a piece of paper and write down exactly how you intend to identify those emoticons. You cannot do it on screen, only on paper. then come back and tell us how you got on
Rupinder Sandhu
Greenhorn

Joined: Mar 13, 2013
Posts: 3
Ok since you pointed that out about the char. I decided to put the emoticons into a Switch statement that deals with Strings.

How do i go through statements and access the Twitter API, and count the emoticons this way?? Please help..



How do I count the emoticons, when it passes through all those cases?

I have also thought of doing an array



But i have no idea, how to carry on. How do i query the array so that it goes through the Twitter api and gives me a count if it catches any of the elements?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
That is not a switch which uses Strings, but a switch which uses ints. It will of course always print null.
There is some poor design there, a class with no methods and no constructor. It might compile, but it is of no use to anybody.
What do you mean by, “// I am unsure, why i need this bit”?
Rupinder Sandhu
Greenhorn

Joined: Mar 13, 2013
Posts: 3
Hey, I managed to solve my problem.

You can close this thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help to count emoticons from a Twitter search API?
 
Similar Threads
Reading an array of numbers from a txt file
searching a string in an HTML file
Regular Expression for Detecting Emoticons
Counting exact matches of substring.
search files in directory for string and return count