benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b6a1c926-6a17-5404-9b11-7649e567a8d2

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import os
import csv
from collections import Counter

def task_func(file_path):
    """
    This function reads the specified CSV file, counts the frequency of each word, and returns the most common word 
    along with its frequency.

    Parameters:
    - file_path (str): The path to the CSV file.

    Requirements:
    - os
    - csv
    - collections

    Returns:
    - tuple: The most common word and its frequency, or None if the file doesn't exist or is empty.

    Example:
    >>> # Assuming 'example.txt' contains multiple repetitions of the word 'example'
    >>> task_func('example.txt')  # doctest: +SKIP
    ('example', <some_positive_integer>)

    Note:
    - The function specifically reads from the given file path.
    - This example uses +SKIP because it relies on external file content.
    """

instruct prompt

This function reads the specified CSV file, counts the frequency of each word, and returns the most common word along with its frequency.
Note that: The function specifically reads from the given file path. This example uses +SKIP because it relies on external file content.
The function should output with:
    tuple: The most common word and its frequency, or None if the file doesn't exist or is empty.
You should write self-contained code starting with:

Code

import os
import csv
from collections import Counter
def task_func(file_path):

code prompt

Code

import os
import csv
from collections import Counter
def task_func(file_path):

entry point

task_func

libs

  • csv
  • collections
  • os

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import