// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x378, %rsp            # imm = 0x378
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x26b8(%rip), %rdi      # 0x9306
callq 0x3370
leaq 0x26cf(%rip), %rdi      # 0x9329
callq 0x3370
pushq $0x60
popq %rdi
callq 0x3230
movq %rax, -0x40(%rbp)
movq %rax, %rdi
callq 0x3b88
xorpd %xmm0, %xmm0
movupd %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq -0x398(%rbp), %rdi
callq 0x3280
leaq -0x398(%rbp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x3180
movq %r14, -0x30(%rbp)
callq 0x3190
movq %rax, %rbx
leaq -0x320(%rbp), %rdi
callq 0x30c0
testb %al, %al
je 0x6e86
movq %rbx, -0x48(%rbp)
leaq -0xb0(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %ebx, %ebx
xorl %r12d, %r12d
leaq -0x398(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3080
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x6e94
leaq -0x150(%rbp), %r13
movq %r13, %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3300
leaq -0x60(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq %r13, %rdx
callq 0x3cd0
movq %r13, %rdi
callq 0x3130
movq -0x60(%rbp), %rsi
addq $0x20, %rsi
leaq -0x130(%rbp), %r13
movq %r13, %rdi
callq 0x3300
leaq -0xa0(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq %r13, %rdx
callq 0x3dd6
movq %r13, %rdi
callq 0x3130
movq -0x60(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x3300
leaq -0x110(%rbp), %r13
movq %r13, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x70a0
leaq -0xd8(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x670e
movq %r13, %rdi
callq 0x44ca
leaq -0x190(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x72b4
movq %r15, %rdi
movq %r13, %rsi
callq 0x6bfa
movss %xmm0, -0x38(%rbp)
movq %r13, %rdi
callq 0x75b8
movss -0x38(%rbp), %xmm0
callq 0x703e
movss 0x54(%r15), %xmm1
movss %xmm0, -0x38(%rbp)
ucomiss %xmm0, %xmm1
sbbl $-0x1, %r12d
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
andq $0x0, -0x80(%rbp)
movb $0x0, -0x78(%rbp)
andl $0x0, -0x68(%rbp)
leaq -0x178(%rbp), %r14
movq %r14, %rdi
leaq -0xf8(%rbp), %rsi
callq 0x3300
movss -0x38(%rbp), %xmm0
movss %xmm0, -0x158(%rbp)
leaq -0x88(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x73d8
movq %r14, %rdi
callq 0x3130
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0x73fe
movq %r13, %rdi
callq 0x3130
leaq -0xd8(%rbp), %rdi
callq 0x75b8
leaq -0xf8(%rbp), %rdi
callq 0x3130
leaq -0xa0(%rbp), %rdi
callq 0x44ca
leaq -0x60(%rbp), %rdi
callq 0x44ca
incl %ebx
jmp 0x6cdb
xorl %r12d, %r12d
xorpd %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0x6ead
leaq -0xc0(%rbp), %rdi
callq 0x3130
cvtsi2sd %ebx, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x48(%rbp), %rbx
callq 0x3190
cvtsi2sd %rax, %xmm1
cvtsi2sd %rbx, %xmm0
subsd %xmm0, %xmm1
divsd 0x2288(%rip), %xmm1     # 0x9150
movsd %xmm1, -0x48(%rbp)
movapd %xmm1, %xmm0
divsd 0x227f(%rip), %xmm0     # 0x9158
callq 0x33b0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm1
mulss 0x2282(%rip), %xmm0     # 0x9170
cvtss2sd %xmm0, %xmm0
addsd -0x48(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm2
cvtsi2sd %r12d, %xmm3
divsd -0x38(%rbp), %xmm3
movsd 0x2253(%rip), %xmm0     # 0x9160
subsd %xmm3, %xmm0
cvtss2sd %xmm2, %xmm2
leaq 0x22cc(%rip), %rdi      # 0x91e8
pushq $0x1
popq %rsi
movl %r12d, %edx
movb $0x3, %al
callq 0x3050
movq 0x7090(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
callq 0x32a0
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
leaq -0x398(%rbp), %rdi
callq 0x30d0
movq -0x30(%rbp), %rax
addq $0x378, %rsp            # imm = 0x378
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x7021
movq %rax, %rbx
jmp 0x702d
movq %rax, %rbx
movq -0x40(%rbp), %rdi
callq 0x3210
jmp 0x7035
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x3130
jmp 0x7011
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x3130
jmp 0x7003
movq %rax, %rbx
jmp 0x6ff7
jmp 0x6fae
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x3130
jmp 0x6fd8
movq %rax, %rbx
jmp 0x7003
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x44ca
jmp 0x6feb
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x75b8
jmp 0x6feb
jmp 0x700e
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
callq 0x3130
leaq -0xa0(%rbp), %rdi
callq 0x44ca
leaq -0x60(%rbp), %rdi
callq 0x44ca
jmp 0x7011
movq %rax, %rbx
movq -0x30(%rbp), %r14
leaq -0xc0(%rbp), %rdi
callq 0x3130
leaq -0x398(%rbp), %rdi
callq 0x30d0
movq %r14, %rdi
callq 0x3a32
movq %rbx, %rdi
callq 0x33e0
nop