benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf c10ec801-5d7e-5bf5-a05e-cea3a87cbe61
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import nltk
from string import punctuation
import pandas as pd
def task_func(text):
"""
Finds all words in a text, that are seperated by whitespace,
beginning with the "
$" character and computes their number of occurences.
Parameters:
text (str): The input text.
Returns:
DataFrame: A pandas DataFrame with two columns: "Word" and "Frequency".
"Word" contains the '$' prefixed words, and "Frequency" contains their occurrences.
Raises:
ValueError: if text is not a string
Requirements:
- nltk
- string
- pandas
Note:
The function ignores words that are entirely made up of punctuation, even if they start with a '$'.
Example:
>>> text = "$abc def hij klm $ $abc hij $hij"
>>> task_func(text)
Word Frequency
0 $abc 3
1 hij 3
>>> text = "s a test $test"
>>> task_func(text)
Word Frequency
0 $hello 1
1 $test 3
"""
Plain-text mathematical notation (without MathML)
import nltk
from string import punctuation
import pandas as pd
def task_func(text):
"""
Finds all words in a text, that are seperated by whitespace,
beginning with the "$" character and computes their number of occurences.
Parameters:
text (str): The input text.
Returns:
DataFrame: A pandas DataFrame with two columns: "Word" and "Frequency".
"Word" contains the '$' prefixed words, and "Frequency" contains their occurrences.
Raises:
ValueError: if text is not a string
Requirements:
- nltk
- string
- pandas
Note:
The function ignores words that are entirely made up of punctuation, even if they start with a '$'.
Example:
>>> text = "$abc def efghij klm $ $abc abchij $hij"
>>> task_func(text)
Word Frequency
0 $abc 3
1 efg12hij 3
>>> text = "hellothisis a testtest $test"
>>> task_func(text)
Word Frequency
0 $hello 1
1 $test 3
"""
Original LaTeX notation
import nltk
from string import punctuation
import pandas as pd
def task_func(text):
"""
Finds all words in a text, that are seperated by whitespace,
beginning with the "$" character and computes their number of occurences.
Parameters:
text (str): The input text.
Returns:
DataFrame: A pandas DataFrame with two columns: "Word" and "Frequency".
"Word" contains the '$' prefixed words, and "Frequency" contains their occurrences.
Raises:
ValueError: if text is not a string
Requirements:
- nltk
- string
- pandas
Note:
The function ignores words that are entirely made up of punctuation, even if they start with a '$'.
Example:
>>> text = "$abc def $efg $hij klm $ $abc $abc $hij $hij"
>>> task_func(text)
Word Frequency
0 $abc 3
1 $efg 1
2 $hij 3
>>> text = "$hello this i$s a $test $test $test"
>>> task_func(text)
Word Frequency
0 $hello 1
1 $test 3
"""
instruct prompt
Finds all words in a text, that are seperated by whitespace, beginning with the "
$" character and computes their number of occurences. >>> text = "$hello this itest test" >>> task_func(text) Word Frequency 0 test 3
Note that: The function ignores words that are entirely made up of punctuation, even if they start with a '$'.
The function should raise the exception for: ValueError: if text is not a string
The function should output with:
DataFrame: A pandas DataFrame with two columns: "Word" and "Frequency".
"Word" contains the '$' prefixed words, and "Frequency" contains their occurrences.
You should write self-contained code starting with:
Plain-text mathematical notation (without MathML)
Finds all words in a text, that are seperated by whitespace, beginning with the "$" character and computes their number of occurences. >>> text = "$hello this isatest testtest" >>> task_func(text) Word Frequency 0 hello11test 3
Note that: The function ignores words that are entirely made up of punctuation, even if they start with a '$'.
The function should raise the exception for: ValueError: if text is not a string
The function should output with:
DataFrame: A pandas DataFrame with two columns: "Word" and "Frequency".
"Word" contains the '$' prefixed words, and "Frequency" contains their occurrences.
You should write self-contained code starting with:
Original LaTeX notation
Finds all words in a text, that are seperated by whitespace, beginning with the "$" character and computes their number of occurences. >>> text = "$hello this i$s a $test $test $test" >>> task_func(text) Word Frequency 0 $hello 1 1 $test 3
Note that: The function ignores words that are entirely made up of punctuation, even if they start with a '$'.
The function should raise the exception for: ValueError: if text is not a string
The function should output with:
DataFrame: A pandas DataFrame with two columns: "Word" and "Frequency".
"Word" contains the '$' prefixed words, and "Frequency" contains their occurrences.
You should write self-contained code starting with:
Code
import nltk
from string import punctuation
import pandas as pd
def task_func(text):
code prompt
Code
import nltk
from string import punctuation
import pandas as pd
def task_func(text):
entry point
task_func
libs
- nltk
- pandas
- string
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
initial import