benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf a84410f5-1634-5d71-ab59-f288f936fb25

Problem

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

complete prompt

import re
import pandas as pd

STOPWORDS = ["Those", "are", "the", "words", "to", "ignore"]


def task_func(text):
    """
    Given a text as input, the function should split it into multiple sentences and build a dictionary where each key is associated with a sentence and the corresponding value is the number of words in the sentence. The function returns a pandas Series built from the dictionary.
    - The keys of the dictionary (which correspond to the Index of the pandas Series) should be named "Sentence 1", "Sentence 2" etc.
    - When counting the words in a sentence, do not consider those included in the constant STOPWORDS.
    - Do not consider empty sentences.

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

    Returns:
    pandas.core.series.Series: A pandas Series each sentence and its number of words that are not in STOPWORDS.

    Requirements:
    - pandas
    - regex

    Example:
    >>> text = "This is a sample sentence. This sentence contains sample words."
    >>> df = task_func("I am good at programming. I learned it in college.")
    >>> print(df)
    Sentence 1    5
    Sentence 2    5
    dtype: int64
    """

instruct prompt

Given a text as input, the function should split it into multiple sentences and build a dictionary where each key is associated with a sentence and the corresponding value is the number of words in the sentence. The function returns a pandas Series built from the dictionary. - The keys of the dictionary (which correspond to the Index of the pandas Series) should be named "Sentence 1", "Sentence 2" etc. - When counting the words in a sentence, do not consider those included in the constant STOPWORDS. - Do not consider empty sentences.
The function should output with:
    pandas.core.series.Series: A pandas Series each sentence and its number of words that are not in STOPWORDS.
You should write self-contained code starting with:

Code

import re
import pandas as pd
STOPWORDS = ["Those", "are", "the", "words", "to", "ignore"]
def task_func(text):

code prompt

Code

import re
import pandas as pd
STOPWORDS = ["Those", "are", "the", "words", "to", "ignore"]
def task_func(text):

entry point

task_func

libs

  • pandas
  • 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