



"""simple docstring"""






from collections.abc import Callable


def     _lowercase       (						__snake_case      ,__snake_case      ,__snake_case			)		->     float:
			__lowerCAmelCase				= a
			__lowerCAmelCase				= b
			if function(__snake_case			) == 0:  # one of the a or b is a root for the function
						return a
			elif function(__snake_case			) == 0:
						return b
			elif (
			    function(__snake_case			) * function(__snake_case			) > 0
			):  # if none of these are root and they are both positive or negative,
						# then this algorithm can't find the root
						raise ValueError("could not find root in given interval."			)
			else:
						__lowerCAmelCase				= start + (end - start) / 2.0
						while abs(start - mid			) > 10**-7:  # until precisely equals to 10^-7
									if function(__snake_case			) == 0:
												return mid
									elif function(__snake_case			) * function(__snake_case			) < 0:
												__lowerCAmelCase				= mid
									else:
												__lowerCAmelCase				= mid
									__lowerCAmelCase				= start + (end - start) / 2.0
						return mid


def     _lowercase       (						__snake_case			)		->     float:
			return x**3 - 2 * x - 5


if __name__ == "__main__":
	print(bisection(f, 1, 1_000))

	import doctest

	doctest.testmod()




"""simple docstring"""






import string
from math import logaa


def     _lowercase       (						__snake_case      ,__snake_case			)		->     int:
			__lowerCAmelCase   :						int				= document.translate(
			    str.maketrans(""      ,""      ,string.punctuation			)			).replace("\n"      ,""			)
			__lowerCAmelCase   :						Dict				= document_without_punctuation.split(" "			)  # word tokenization
			return len([word for word in tokenize_document if word.lower() == term.lower()]			)


def     _lowercase       (						__snake_case      ,__snake_case			)		->     tuple[int, int]:
			__lowerCAmelCase   :						Optional[Any]				= corpus.lower().translate(
			    str.maketrans(""      ,""      ,string.punctuation			)			)  # strip all punctuation and replace it with ''
			__lowerCAmelCase   :						List[str]				= corpus_without_punctuation.split("\n"			)
			__lowerCAmelCase   :						str				= term.lower()
			return (len([doc for doc in docs if term in doc]			), len(__snake_case			))


def     _lowercase       (						__snake_case      ,__snake_case      ,__snake_case=False			)		->     float:
			if smoothing:
						if n == 0:
									raise ValueError("log10(0) is undefined."			)
						return round(1 + logaa(n / (1 + df)			)      ,3			)

			if df == 0:
						raise ZeroDivisionError("df must be > 0"			)
			elif n == 0:
						raise ValueError("log10(0) is undefined."			)
			return round(logaa(n / df			)      ,3			)





def     _lowercase       (						__snake_case      ,__snake_case			)		->     float:
			return round(tf * idf      ,3			)