Computing desk | ||
---|---|---|
< February 22 | << Jan | February | Mar >> | February 24 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
I've recently worked out the details for implementing a specific real-time sample rate conversion algorithm. There is a lot of information online about the basic technique, but next to nothing focused on how to actually get from the theory to functional code. Working it out took a lot of jumping between several different references to tie together all the details. I'd like to write up a nice article describing how the method works and how to actually implement it so that other people can benefit from it, but I don't know of a good place to publish it online. It's the sort of thing I would have published on my blog, but it's been offline for a few years and I don't want to revive it now. Katie R (talk) 02:46, 23 February 2014 (UTC)
I'm working on a project where I perform sentiment analysis on tweets, and I'm trying to stream Hindi tweets and write them in a file in a human-readable form. I've tried the following piece of code for writing the Hindi data to a .txt file.
with open("C://Users/User/Desktop/hindistream.txt","ab") as f:
f.write(tweet.decode("UTF-8").encode("UTF-8"))
f.close()
Funnily, the code works when I give it a variable tweet="भारत का इतिहास काफी समृद्ध एवं विस्तृत है।" or something along those lines, but doesn't work when I plug it into the twitter-streaming code as below:
class listener(StreamListener):
def on_data(self, data):
try:
tweet = data.split(',"text":"')[1].split('","source":')[0]
tweet = tweet.decode("utf-8")
print tweet
with open("C://Users/User/Desktop/hindistream.txt", "a") as f:
f.write(tweet.encode("UTF-8"))
f.close()
return True
except BaseException, e:
print 'failed ondata,',str(e)
time.sleep(5)
def on_error(self,status):
print status
The data does get written, but it's encoded (the text becomes something like "\u0939\u0948\u0902", instead of Hindi characters). Can anybody tell me where I'm going wrong? La Alquimista 06:04, 23 February 2014 (UTC)
I'm not sure how to. >_< I'm a rookie still, and much of the code has been stitched from multiple pre-existing snippets... You mean I should not use the split() function? What equivalent function does the json library have? La Alquimista 08:52, 23 February 2014 (UTC)
data = json.loads(data.decode('utf-8'))
tweet = data['text']
Thank you! It totally worked! A barnstar to you sir! However, I have a follow up question. Earlier, I was using the split() function to get the main tweet that appeared inside all that code (the tweets always appeared between "text:" and "source:", so I had made that the criteria for my split). But this code appears to work fine just with 'text'. How does that work. How does python know where to stop extracting the tweet from? La Alquimista 15:44, 23 February 2014 (UTC)
some friends of mine have decided to set up a small minecraft server, so we can all play together, seems a good idea, but for some reason even the computer experts are flailing around trying to find a way of linking us all to the game. Originally we tried hamatchi, but it kept dropping out or not working properly, so we switched to something called tunngle, seems to be working, but it's throwing adverts at us all the time and generally being annoying. Anyone know of a simpler, less intrusive way we can get something set up? I don't know much about computers, but I get the impression these programs are effectively doing something we could set up ourselves without their help, perhaps with better server hardware/software? or perhaps not, maybe we just need a better program to run the connection for us? any thoughts?
many thanks,
94.8.179.211 (talk) 19:14, 23 February 2014 (UTC)
at the moment I am running both Windows and Mint, and have the option to install another OS if needed, though it'd need to be something others can access through Windows devices. We have the extra hardware to set up a physical server within my house if that would be easier? (assuming it can't, or at least shouldn't, be hosted off the same commercial server account my websites are on) 94.8.179.211 (talk) 11:31, 24 February 2014 (UTC)