# RB: Ruble-based, LB: Lexicon-base, ML: Machine Learning classifier
count = {'RB': 0, 'LB': 0, 'ML': 0}

# Evaluate if tested with the gold standard
guess = list()
gold = list()

# Keep the predictions string
output = ''

# Load test set tweets
#tweets = [tweet['MESSAGE'] for tweet in devset]
tweets = [tweet['MESSAGE'] for tweet in testset]

# Classify each instance in the testeset in the TwitterHybridClassifier loaded before
predictions = classifier.classify_batch(tweets)

print("features test size -> " + str(len(var.features_test)))

#import pickle

#pickle_out = open("../../featuresTest.pickle","ab")
#pickle.dump(var.features_test, pickle_out)
#pickle_out.close()

# Output the semeval prediction file and the evaluation variables
# if testset if provided
if len(testset) > 0:
    for index, tweet in enumerate(testset):
        prediction, method = predictions[index]
        count[method] += 1
# RB: Ruble-based, LB: Lexicon-base, ML: Machine Learning classifier
count = {'RB':0, 'LB':0, 'ML':0 }

# Evaluate if tested with the gold standard
guess = list()
gold = list()

# Keep the predictions string
output = ''

# Load test set tweets
#tweets = [tweet['MESSAGE'] for tweet in devset]
tweets = [tweet['MESSAGE'] for tweet in testset]

# Classify each instance in the testeset in the TwitterHybridClassifier loaded before
predictions = classifier.classify_batch(tweets)

# Output the semeval prediction file and the evaluation variables
# if testset if provided
if len(testset) > 0:
    for index, tweet in enumerate(testset):
        prediction,method = predictions[index]
        count[method] += 1
        output += tweet['SID'] + '\t' + tweet['UID'] + '\t' + prediction + '\t' + tweet['MESSAGE'] + '\n'
        guess.append(prediction)
        gold.append(tweet['SENTIMENT'])
    confusion_matrix(gold,guess)

    # Write Semeval output file
    output_file = 'task9-NILC_USP-B-twitter-constrained.output'
    codecs.open(output_file,'w','utf8').write(output)