0 out of 68 challenges solved

Count the frequency of words in a file

Question:
Write a function called count_word_frequency that takes a file path as input and returns a dictionary containing the frequency of each word in the file. The function should read the file, tokenize the words, and count their occurrences.

Example:
Input: "sample.txt"
Output: {"Hello": 2, "world": 1, "Python": 3}

def count_word_frequency(file_path):
    """
    Counts the frequency of each word in a file.

    Args:
        file_path (str): The path to the input file.

    Returns:
        dict: A dictionary containing the word frequency.
    """
    # TODO: Implement the count_word_frequency function
    pass