benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 68a53204-325c-5208-9aed-437a3ab15baa

Problem

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

complete prompt

from nltk.tokenize import RegexpTokenizer from collections import Counter def task_func(text): """ Identifies and counts words in a given text that start with the "$" symbol. It returns the five most frequent dollar-prefixed words along with their counts. Words solely consisting of "$" symbols without any following alphanumeric characters are ignored in the frequency count. Parameters: - text (str): The input text to analyze. Returns: - list of tuples: Each tuple contains a dollar-prefixed word (excluding the "$" symbol) and its frequency, ordered by most to least common. Requirements: - nltk.tokenize.RegexpTokenizer - collections.Counter Example: >>> text = "$abc def efgefg hij klm $ $abc abcabc hij $hij" >>> task_func(text) [('abc', 3), ('hij', 3), ('efg', 1)] """
Plain-text mathematical notation (without MathML)
from nltk.tokenize import RegexpTokenizer
from collections import Counter


def task_func(text):
    """
    Identifies and counts words in a given text that start with the "$" symbol. It returns the five most frequent
    dollar-prefixed words along with their counts. Words solely consisting of "$" symbols without any following
    alphanumeric characters are ignored in the frequency count.

    Parameters:
    - text (str): The input text to analyze.

    Returns:
    - list of tuples: Each tuple contains a dollar-prefixed word (excluding the "$" symbol) and its frequency,
                      ordered by most to least common.

    Requirements:
    - nltk.tokenize.RegexpTokenizer
    - collections.Counter

    Example:
    >>> text = "$abc def efghij klm $ $abc abchij $hij"
    >>> task_func(text)
    [('abc', 3), ('hij', 3), ('efg', 1)]
    """
Original LaTeX notation
from nltk.tokenize import RegexpTokenizer
from collections import Counter


def task_func(text):
    """
    Identifies and counts words in a given text that start with the "$" symbol. It returns the five most frequent
    dollar-prefixed words along with their counts. Words solely consisting of "$" symbols without any following
    alphanumeric characters are ignored in the frequency count.

    Parameters:
    - text (str): The input text to analyze.

    Returns:
    - list of tuples: Each tuple contains a dollar-prefixed word (excluding the "$" symbol) and its frequency,
                      ordered by most to least common.

    Requirements:
    - nltk.tokenize.RegexpTokenizer
    - collections.Counter

    Example:
    >>> text = "$abc def $efg $hij klm $ $abc $abc $hij $hij"
    >>> task_func(text)
    [('abc', 3), ('hij', 3), ('efg', 1)]
    """

instruct prompt

Identifies and counts words in a given text that start with the "$" symbol. It returns the five most frequent dollar-prefixed words along with their counts. Words solely consisting of "$" symbols without any following alphanumeric characters are ignored in the frequency count. The function should output with: list of tuples: Each tuple contains a dollar-prefixed word (excluding the "$" symbol) and its frequency, ordered by most to least common. You should write self-contained code starting with:
Plain-text mathematical notation (without MathML)
Identifies and counts words in a given text that start with the "$" symbol. It returns the five most frequent dollar-prefixed words along with their counts. Words solely consisting of "$" symbols without any following alphanumeric characters are ignored in the frequency count.
The function should output with:
    list of tuples: Each tuple contains a dollar-prefixed word (excluding the "$" symbol) and its frequency,
    ordered by most to least common.
You should write self-contained code starting with:
Original LaTeX notation
Identifies and counts words in a given text that start with the "$" symbol. It returns the five most frequent dollar-prefixed words along with their counts. Words solely consisting of "$" symbols without any following alphanumeric characters are ignored in the frequency count.
The function should output with:
    list of tuples: Each tuple contains a dollar-prefixed word (excluding the "$" symbol) and its frequency,
    ordered by most to least common.
You should write self-contained code starting with:

Code

from nltk.tokenize import RegexpTokenizer
from collections import Counter
def task_func(text):

code prompt

Code

from nltk.tokenize import RegexpTokenizer
from collections import Counter
def task_func(text):

entry point

task_func

libs

  • nltk
  • collections

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