Created
June 5, 2018 06:09
-
-
Save ssisaias/08b2c8494a4553612987c9d4ae94f86c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 2018 - Isaias S. Silva | |
# This script converts the sentistrength output to a CSV one with zeros and ones, so we can use in a two class classifier. | |
import requests | |
import time | |
import datetime | |
import sys | |
import json | |
#Attention to the file names bellow | |
output_file = open('output_results_processed.txt', 'w', encoding='utf-8') | |
output_file.close() | |
output_file = open('output_results_processed.txt', 'a', encoding='utf-8') | |
with open('output+results.txt','r', encoding='utf-8') as myFile: | |
cont = 1 | |
line = myFile.readline() | |
while line: | |
phrase = line.split(' ') | |
#print(phrase[0]) ## frase | |
#print(phrase[1]) ## positivo | |
#print(phrase[2]) ## negativo | |
n1 = abs(int(phrase[1])) | |
n2 = abs(int(phrase[2])) | |
#ignore empty lines | |
if(phrase[0].strip()==""): | |
print(str(cont)+ " Vazio: "+ phrase[0]) | |
line = myFile.readline() | |
cont+=1 | |
time.sleep(0.1) | |
continue | |
if n1 == n2: | |
print('neutro') | |
output_file.write(phrase[0]+","+"0\n") | |
elif n1 > n2: | |
print('positivo!') | |
output_file.write(phrase[0]+","+"0\n") | |
else: | |
print('negativo!') | |
output_file.write(phrase[0]+","+"1\n") | |
line = myFile.readline() | |
cont+=1 | |
#time.sleep(0.2) | |
output_file.close() | |
print('Completed!') | |
#quando meu primo fica aqui ele só assisti parabéns galinha 1 -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment