コード例 #1
0
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]
コード例 #2
0
dic = load_dic()
for line in arr:
    x.append(apply_dic(dic, line))
    polarity = qq2.opn_classify(line)
    if polarity==None or (polarity>2 and polarity <4):
        gold.append(0)
    elif(polarity<=2):
        gold.append(2)
    else:
        gold.append(1)

    index+=1


ans = svm.classify(vectors=x)

match=0
total=0
for i in range(0,len(ans)):

    if(ans[i]==gold[i]):
        match+=1
        total+=1
    elif(gold[i]!=0):
        total+=1
    else:
        print str(ans[i]) + " " + str(gold[i])

print "###############################"
print str(match) + " " + str(total)