📜 ⬆️ ⬇️

Linq To Twitter: Finding the words, hash tags and interlocutors themselves

Recently, the network began to walk the link to the project http://tweetcloud.icodeforlove.com/ (they wrote about it here ), which could count the number of words used in your messages on twitter and draw a graph. But this project had several big flaws: Russian words were not considered, after counting, he wrote in tweet - spam to himself. Maybe there are some other flaws: the first two were enough for me to not watch this project. But, remember the wonderful product LinqToTwitter , which I already wrote about . Well, it is clear that counting the number of words will not be difficult.

Therefore, we take WPF + LinqToTwitter, a couple of evenings and our tag cloud is ready:

Capture
')
I’ll say right away that while writing me like I’ve been banned on TwitterAPI a couple of times (LinqToTwitter should work with it), I added Thread.Sleep (200) at intervals of requests in order to unload it at least, but problems remained - less often, but there are, so consider ( do not get carried away ). After the ban, clients will not work for about a day. I have 800 tweets loaded and processed for about a minute, calculate the time yourself - how much you need to count your words.

Program


Now a few words about the program itself and the interface. In the upper right corner we drive in a user and password and press the Create Cloud button, a progress bar has gone, which can be stopped at any time with the Stop button (to its right). If you need to take out some words from the statistics, enter them separated by a comma or a space in the Parasites words field. At first I wanted to fill in as many words as possible, and then I thought that all the same I wondered how many words of parasites I really use, so by default there was not enough. I broke the statistics by words into three groups: “Words”, “Hash tags”, “Users”. Also, the program next to it puts a log file in which it writes all the tweets it has downloaded.

After downloading, and indeed at any time, you can click on the twitter logo and save the screenshot of the program to a * .png file.

Insides


What I had and what I used inside. Well, of course, LinqToTwitter, which I had to rebuild myself and throw dependencies on the DotNetOpenAuth.dll and Kerr.Credentials.dll libraries, because the assembly did not work with them on My CPU, the Kerr.Credentials.dll did not load at startup ( x64) For visualization used WPF - because quickly and angrily. In order for the PasswordBox field to be able to bind, it took a solution from here (consider this unsafe solution, it’s not just the way that PasswordBox was made without the ability to set Binding on the Password field). The task of collecting statistics works as a separate thread, again with the help of my favorite BackgroundWorker . Well, saving the screenshot of the program was made possible thanks to this note.

I broke into words like this:

string [] words = tweet.Text.Split( new [] { ' ' , '.' , ',' , '?' , '!' }, StringSplitOptions.RemoveEmptyEntries);

* This source code was highlighted with Source Code Highlighter .


Therefore, if these character sets are not enough for you, add your own. ')' and '(' I didn’t use it, now I think it would be necessary to add '-', probably. When reading tweets, the program also adds them to the log next to them by date. This is in case of - if you want see if this is really your twitter.

In general, the code there is quite simple. Initially, I even thought to add a database (Compact) for the history of tweets, in order not to download a second time, also to make it possible to search for downloaded tweets, well, and some other ideas ... But for now, leave it like that, if someone has a desire something correct - the code there is simple and clear - correct. Make suggestions, maybe in the future and add something else, if there is a demand. Good luck!

Links




PS User

Progg it

Source: https://habr.com/ru/post/77150/


All Articles