benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 58c2c161-96b0-591b-9a75-5f1aa8974a16

Problem

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

complete prompt

import re
from nltk import word_tokenize
from collections import Counter

def task_func(input_str):
    """
    Remove all special characters, punctuation marks and spaces from a string called "input _ str" using regex and then count the frequency of each word.

    Parameters:
    input_str (str): The input string.

    Returns:
    dict: A dictionary with the frequency of each word.

    Requirements:
    - re
    - nltk.word_tokenize
    - collections.Counter

    Example:
    >>> task_func('Special $#! characters   spaces 888323')
    Counter({'Special': 1, 'characters': 1, 'spaces': 1, '888323': 1})
    """

instruct prompt

Remove all special characters, punctuation marks and spaces from a string called "input _ str" using regex and then count the frequency of each word.
The function should output with:
    dict: A dictionary with the frequency of each word.
You should write self-contained code starting with:

Code

import re
from nltk import word_tokenize
from collections import Counter
def task_func(input_str):

code prompt

Code

import re
from nltk import word_tokenize
from collections import Counter
def task_func(input_str):

entry point

task_func

libs

  • nltk
  • collections
  • re

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