benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b4060bb0-9dce-5f15-8e41-7d0cfde2c2e8

Problem

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

complete prompt

import re
from collections import Counter


def task_func(text, top_n):
    """
    Count the N most common words in a text after removing URLs.

    Parameters:
    text (str): The text to analyze.
    top_n (int): The number of top words to return.

    Returns:
    list: A list of tuples where each tuple contains a word and its frequency.

    Requirements:
    - re
    - collections.Counter

    Example:
    >>> task_func('Visit https://www.python.org for more info. Python is great. I love Python.', 2)
    [('Python', 2), ('Visit', 1)]

    Note:
    - Valid url is start with http or https
    """

instruct prompt

Count the N most common words in a text after removing URLs.
Note that: Valid url is start with http or https
The function should output with:
    list: A list of tuples where each tuple contains a word and its frequency.
You should write self-contained code starting with:

Code

import re
from collections import Counter
def task_func(text, top_n):

code prompt

Code

import re
from collections import Counter
def task_func(text, top_n):

entry point

task_func

libs

  • 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