benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f3bd5fd8-2ceb-5572-8935-db10e9793d9b

Problem

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

complete prompt

import re
import string
from nltk.stem import PorterStemmer
from collections import Counter

STEMMER = PorterStemmer()

def task_func(content):
    """
    Stem every word in a sentence, except the last, and count the frequency of each stem.

    Parameters:
    content (str): The sentence to stem and count.

    Returns:
    dict: A dictionary with stemmed words as keys and their frequency as values.

    Requirements:
    - re
    - string
    - nltk.stem
    - collections.Counter

    Example:
    >>> task_func('running runner run')
    {'run': 1, 'runner': 1}
    """

instruct prompt

Stem every word in a sentence, except the last, and count the frequency of each stem.
The function should output with:
    dict: A dictionary with stemmed words as keys and their frequency as values.
You should write self-contained code starting with:

Code

import re
import string
from nltk.stem import PorterStemmer
from collections import Counter
STEMMER = PorterStemmer()
def task_func(content):

code prompt

Code

import re
import string
from nltk.stem import PorterStemmer
from collections import Counter
STEMMER = PorterStemmer()
def task_func(content):

entry point

task_func

libs

  • nltk
  • collections
  • string
  • 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