def classify(str): global dic global subs svm = SVMLight("/home/xorox90/svm", model="polar", cleanup=True) x = [] x.append(apply_dic(dic,str)) return subs[svm.classify(vectors=x)[0]-1]
def test(): con = MySQLdb.connect(db='twit_manager', host="61.43.139.70",user='******', passwd='1rmdwjd', charset="UTF8") cur = con.cursor(cursorclass=MySQLdb.cursors.DictCursor) cur.execute("select * from tweet_data order by no desc limit 10000") qq2 = JSONRPCProxy("http://61.43.139.70:11001") for tt in cur.fetchall(): print qq2.opn_classify(tt['tweet']) print tt['tweet'] #classify_init() test() exit(0) svm = SVMLight("/home/xorox90/svm", model="polar_model", cleanup=True) ans = [] gold = [] x = [] index =1 qq = JSONRPCProxy("http://61.43.139.70:8000") qq2 = JSONRPCProxy("http://office2.buzzni.com:10100") con = MySQLdb.connect(db='twit_manager', host="61.43.139.70",user='******', passwd='1rmdwjd', charset="UTF8") cur = con.cursor(cursorclass=MySQLdb.cursors.DictCursor) cur.execute("select * from tweet_data order by no desc limit 10000") arr = [] for tt in cur.fetchall(): arr.append(tt['tweet'])