import decimal


def precision(qtd_true_positives, list_of_true_negative_documents, ref=0):
	"""TP / (TP + FP)
	TP - True Positive
	FP - False Positive - a document is negative but classified as positive
	"""

	fp = 0
	for d in list_of_true_negative_documents:
		if d.predicted_polarity > ref:
			fp = fp + 1
	qtd_true_positives = decimal.Decimal(qtd_true_positives)
	fp = decimal.Decimal(fp)
	return (qtd_true_positives / (qtd_true_positives + fp))