// File: /workspace/github_cpp_makefile_star2_O2/aleperno[P]Datos/main.cpp
// Function: main
int main( int argc, char* args[] ) {

	//Se le pasará como argumento el archivo labeledTrainData.tsv (preparseado).
	char* learningPath = args[1];

	// path de análisis
	char* testPath = args[2];

	//El valor con el que se inicializara los pesos del perceptron
	float init = atoi(args[3]);

	// Metodo Perceptron
	unsigned int hash_size = pow(2,25);
	float learning_rate = 0.1 * log(2);
	HashingPerceptron* perceptron = new HashingPerceptron(learningPath,3, learning_rate ,hash_size,init);

	//Levanto y parseo el archivo a analizar
	//Parser* parser = new Parser();

	//ifstream testfile;
	//testfile.open(testPath);

	/*
	vector<string> id_reviews;
	vector<float> scoresP;
	//Utilizo para normalizar los resultados del perceptron
	printf("Comienzo a evaluar el set de prueba\n");
	if(testfile.is_open())
	{
		string linea;
		while( getline(testfile,linea) )
		{
			vector<string> tokenized_columns = parser->tokenizeColumns(linea);
			vector<string> tokenized_words = parser->tokenizeReviews(tokenized_columns[1]); //TODO cero porque solo son strings

			id_reviews.push_back(tokenized_columns[0]);

			float score = perceptron->rate(tokenized_words);
			scoresP.push_back(score);
		}
	}
	*/
	//delete parser;
	vector<pair<string,float>> result = perceptron->rate(testPath);
	//Imprimo los resultados
	ofstream outfile("popcorn.csv");
	outfile << "\"id\",\"sentiment\"" << endl;

	for (unsigned int i=0; i < result.size(); i++)
	{
		outfile << result[i].first +"," << result[i].second <<endl;
	}
	outfile.close();

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq 0x8(%rsi), %r15
movq 0x10(%rsi), %rbx
movq 0x18(%rsi), %rdi
callq 0x3380
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x2c(%rbp)
movl $0xa0, %edi
callq 0x3230
movq %rax, %r14
pushq $0x3
popq %rdx
movss 0x5748(%rip), %xmm0     # 0x9004
movq %rax, %rdi
movq %r15, %rsi
movl $0x2000000, %ecx        # imm = 0x2000000
movss -0x2c(%rbp), %xmm1
callq 0x6218
leaq -0x48(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x6c2a
leaq 0x5727(%rip), %rsi      # 0x900e
leaq -0x268(%rbp), %rdi
pushq $0x10
popq %rdx
callq 0x3260
leaq 0x571d(%rip), %rsi      # 0x901a
leaq -0x268(%rbp), %rdi
callq 0x3220
movq %rax, %rdi
callq 0x3140
xorl %r12d, %r12d
pushq $0x28
popq %r13
leaq -0x68(%rbp), %r14
leaq -0x268(%rbp), %r15
movl %r12d, %r12d
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rax
subq %rsi, %rax
cqto
idivq %r13
cmpq %r12, %rax
jbe 0x3983
imulq $0x28, %r12, %rbx
addq %rbx, %rsi
movq %r14, %rdi
leaq 0x56bc(%rip), %rdx      # 0x9008
callq 0x39fa
movq %r15, %rdi
movq %r14, %rsi
callq 0x3200
movq -0x48(%rbp), %rcx
movss 0x20(%rcx,%rbx), %xmm0
movq %rax, %rdi
callq 0x31c0
movq %rax, %rdi
callq 0x3140
movq %r14, %rdi
callq 0x3130
incl %r12d
jmp 0x3923
leaq -0x268(%rbp), %rdi
callq 0x3330
leaq -0x268(%rbp), %rdi
callq 0x3350
leaq -0x48(%rbp), %rdi
callq 0x3a32
xorl %eax, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x39e9
movq %rax, %rbx
movq %r14, %rdi
callq 0x3210
jmp 0x39f2
jmp 0x39cc
movq %rax, %rbx
jmp 0x39dd
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x3130
leaq -0x268(%rbp), %rdi
callq 0x3350
leaq -0x48(%rbp), %rdi
callq 0x3a32
movq %rbx, %rdi
callq 0x33e0