// File: aleperno[P]Datos/HashingPerceptron.cpp
// Function: HashingPerceptron::rate[abi:cxx11](char*)
vector<pair<string,float>> HashingPerceptron::rate(char* testPath)
{
	printf("Began to test the test set dataset\n");
	printf("\nIteration \t Errors \t Average \t Time \n");
	//Instancio el parser
	Parser* parser = new Parser();
	vector<pair<string,float>> aux_vec;
	ifstream testfile;
	testfile.open(testPath);
	//Elementos para informacion adicional
	int error_count = 0;
	int rev_counter = 0;
	clock_t inicio = clock();
	if(testfile.is_open())
	{
		string linea;
		while( getline(testfile,linea) )
		{
			rev_counter++;
			vector<string> tokenized_columns = parser->tokenizeColumns(linea);
			vector<string> tokenized_words = parser->tokenizeReviews(tokenized_columns[1]);

			string doc_id = tokenized_columns[0];

			vector<unsigned int> vec_review = this->getVector(tokenized_words);

			float score = this->dot_product(vec_review);
			score = this->sigmoid(score);

			//Supongo que todos los reviews son positivos
			if (score <= this->threshold) error_count++;

			pair<string,float> par_aux;
			par_aux = make_pair(doc_id,score);
			aux_vec.push_back(par_aux);	
		}
	}
	double final = clock();
	double secs = double(final - inicio) / CLOCKS_PER_SEC;
	float min = floor(secs/60);
	float sec = secs - min*60;
	printf("%d\t\t%d\t\t%0.5f\t\t%.0f:%.3f\n",1,error_count, 1.0 - (double)error_count/rev_counter,min,sec);
	fflush(stdout);
	delete parser;
	//vector<unsigned int> aux_vec = this->getVector(review);
	//float result = this->dot_product(aux_vec);
	//return this->sigmoid(result);
	return aux_vec;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movq %rdi, -0x3d8(%rbp)
movq %rdi, %rax
movq %rax, -0x3d0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x3c8(%rbp)
leaq 0x84f1(%rip), %rdi      # 0x172fb
xorl %eax, %eax
movb %al, -0x3b9(%rbp)
callq 0x4060
movb -0x3b9(%rbp), %al
leaq 0x84fb(%rip), %rdi      # 0x1731f
callq 0x4060
movl $0x60, %edi
callq 0x42e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x3b8(%rbp)
callq 0x5450
jmp 0xee47
movq -0x3d8(%rbp), %rdi
movq -0x3b8(%rbp), %rax
movq %rax, -0x20(%rbp)
movb $0x0, -0x2d(%rbp)
callq 0x10240
leaq -0x238(%rbp), %rdi
callq 0x4370
jmp 0xee70
movq -0x18(%rbp), %rsi
leaq -0x238(%rbp), %rdi
movl $0x8, %edx
callq 0x41b0
jmp 0xee87
movl $0x0, -0x23c(%rbp)
movl $0x0, -0x240(%rbp)
callq 0x41c0
movq %rax, -0x248(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x44c0
movb %al, -0x3d9(%rbp)
jmp 0xeebb
movb -0x3d9(%rbp), %al
testb $0x1, %al
jne 0xeeca
jmp 0xf2db
leaq -0x268(%rbp), %rdi
callq 0x4440
leaq -0x238(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x40a0
movq %rax, -0x3e8(%rbp)
jmp 0xeef2
movq -0x3e8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x43c0
movb %al, -0x3e9(%rbp)
jmp 0xef10
movb -0x3e9(%rbp), %al
testb $0x1, %al
jne 0xef1f
jmp 0xf2bc
movl -0x240(%rbp), %eax
incl %eax
movl %eax, -0x240(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x3f8(%rbp)
leaq -0x2a0(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x4130
jmp 0xef4d
movq -0x3f8(%rbp), %rsi
leaq -0x280(%rbp), %rdi
leaq -0x2a0(%rbp), %rdx
callq 0x5660
jmp 0xef69
leaq -0x2a0(%rbp), %rdi
callq 0x41a0
movq -0x20(%rbp), %rax
movq %rax, -0x400(%rbp)
leaq -0x280(%rbp), %rdi
movl $0x1, %esi
callq 0x4e10
movq %rax, %rsi
leaq -0x2d8(%rbp), %rdi
callq 0x4130
jmp 0xefa2
movq -0x400(%rbp), %rsi
leaq -0x2b8(%rbp), %rdi
leaq -0x2d8(%rbp), %rdx
callq 0x5890
jmp 0xefbe
leaq -0x2d8(%rbp), %rdi
callq 0x41a0
xorl %eax, %eax
movl %eax, %esi
leaq -0x280(%rbp), %rdi
callq 0x4e10
movq %rax, %rsi
leaq -0x2f8(%rbp), %rdi
callq 0x4130
jmp 0xefeb
leaq -0x328(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0xf5b0
jmp 0xf000
movq -0x3c8(%rbp), %rsi
leaq -0x310(%rbp), %rdi
leaq -0x328(%rbp), %rdx
callq 0xe250
jmp 0xf01c
leaq -0x328(%rbp), %rdi
callq 0x69d0
leaq -0x348(%rbp), %rdi
leaq -0x310(%rbp), %rsi
callq 0xfd70
jmp 0xf03d
movq -0x3c8(%rbp), %rdi
leaq -0x348(%rbp), %rsi
movq %rsi, -0x410(%rbp)
callq 0xed30
movq -0x410(%rbp), %rdi
movss %xmm0, -0x408(%rbp)
callq 0xf8d0
movss -0x408(%rbp), %xmm0
movq -0x3c8(%rbp), %rdi
movss %xmm0, -0x32c(%rbp)
movss -0x32c(%rbp), %xmm0
callq 0xf440
movss %xmm0, -0x404(%rbp)
jmp 0xf099
movq -0x3c8(%rbp), %rax
movss -0x404(%rbp), %xmm0
movss %xmm0, -0x32c(%rbp)
movss -0x32c(%rbp), %xmm1
movss 0x54(%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0xf1c5
movl -0x23c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x23c(%rbp)
jmp 0xf1c5
movq -0x3b8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x42b0
jmp 0xf437
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xf42b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xf401
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xf2ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x41a0
jmp 0xf2ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xf2ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x41a0
jmp 0xf2ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xf2a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xf296
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x328(%rbp), %rdi
callq 0x69d0
jmp 0xf296
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xf28a
leaq -0x370(%rbp), %rdi
callq 0x10260
jmp 0xf1d3
leaq -0x398(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
leaq -0x32c(%rbp), %rdx
callq 0x10290
jmp 0xf1ef
leaq -0x370(%rbp), %rdi
movq %rdi, -0x418(%rbp)
leaq -0x398(%rbp), %rsi
movq %rsi, -0x420(%rbp)
callq 0x102d0
movq -0x420(%rbp), %rdi
callq 0x51a0
movq -0x3d8(%rbp), %rdi
movq -0x418(%rbp), %rsi
callq 0x10310
jmp 0xf231
leaq -0x370(%rbp), %rdi
callq 0x51a0
leaq -0x310(%rbp), %rdi
callq 0xf8d0
leaq -0x2f8(%rbp), %rdi
callq 0x41a0
leaq -0x2b8(%rbp), %rdi
callq 0x69d0
leaq -0x280(%rbp), %rdi
callq 0x69d0
jmp 0xeed6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x51a0
leaq -0x310(%rbp), %rdi
callq 0xf8d0
leaq -0x2f8(%rbp), %rdi
callq 0x41a0
leaq -0x2b8(%rbp), %rdi
callq 0x69d0
leaq -0x280(%rbp), %rdi
callq 0x69d0
jmp 0xf2ca
leaq -0x268(%rbp), %rdi
callq 0x41a0
jmp 0xf2db
leaq -0x268(%rbp), %rdi
callq 0x41a0
jmp 0xf401
callq 0x41c0
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x3a0(%rbp)
movsd -0x3a0(%rbp), %xmm0
cvtsi2sdq -0x248(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd 0x7e86(%rip), %xmm1     # 0x17190
divsd %xmm1, %xmm0
movsd %xmm0, -0x3a8(%rbp)
movsd -0x3a8(%rbp), %xmm0
movsd 0x7e72(%rip), %xmm1     # 0x17198
divsd %xmm1, %xmm0
callq 0x4500
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x3ac(%rbp)
movsd -0x3a8(%rbp), %xmm0
movss -0x3ac(%rbp), %xmm1
movss 0x7e5d(%rip), %xmm2     # 0x171b0
mulss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x3b0(%rbp)
movl -0x23c(%rbp), %edx
cvtsi2sd %edx, %xmm1
cvtsi2sdl -0x240(%rbp), %xmm0
divsd %xmm0, %xmm1
movsd 0x7e17(%rip), %xmm0     # 0x171a0
subsd %xmm1, %xmm0
movss -0x3ac(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movss -0x3b0(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x7ec3(%rip), %rdi      # 0x1726f
movl $0x1, %esi
movb $0x3, %al
callq 0x4060
jmp 0xf3ba
movq 0x13bf7(%rip), %rax     # 0x22fb8
movq (%rax), %rdi
callq 0x4390
jmp 0xf3cb
movq -0x20(%rbp), %rax
movq %rax, -0x428(%rbp)
cmpq $0x0, %rax
je 0xf3e9
movq -0x428(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movb $0x1, -0x2d(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x40e0
testb $0x1, -0x2d(%rbp)
jne 0xf41b
jmp 0xf40f
leaq -0x238(%rbp), %rdi
callq 0x40e0
jmp 0xf42b
movq -0x3d8(%rbp), %rdi
callq 0x5010
movq -0x3d0(%rbp), %rax
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
movq -0x3d8(%rbp), %rdi
callq 0x5010
movq -0x28(%rbp), %rdi
callq 0x4550