benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf c99432d9-729e-5d42-9e76-419c00707804
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 string import punctuation
import csv
import os
PUNCTUATION = set(punctuation)
def task_func(text, filename):
"""
Save all words in a text beginning with the "
$" character in a CSV file, excluding any words that are solely composed of punctuation characters.
Parameters:
text (str): The input text.
filename (str): The name of the CSV file to save the '$' words.
Returns:
str: The absolute path of the saved CSV file.
Note:
- The header of the csv row is "Word"
Requirements:
- nltk.tokenize.RegexpTokenizer
- string.punctuation
- csv
- os
Example:
>>> text = "efg abc hij"
>>> task_func(text, 'dollar_words.csv')
'/absolute/path/to/dollar_words.csv'
"""
Plain-text mathematical notation (without MathML)
from nltk.tokenize import RegexpTokenizer
from string import punctuation
import csv
import os
PUNCTUATION = set(punctuation)
def task_func(text, filename):
"""
Save all words in a text beginning with the "$" character in a CSV file, excluding any words that are solely composed of punctuation characters.
Parameters:
text (str): The input text.
filename (str): The name of the CSV file to save the '$' words.
Returns:
str: The absolute path of the saved CSV file.
Note:
- The header of the csv row is "Word"
Requirements:
- nltk.tokenize.RegexpTokenizer
- string.punctuation
- csv
- os
Example:
>>> text = "abcdefefg hijklm abcabc hijhij"
>>> task_func(text, 'dollar_words.csv')
'/absolute/path/to/dollar_words.csv'
"""
Original LaTeX notation
from nltk.tokenize import RegexpTokenizer
from string import punctuation
import csv
import os
PUNCTUATION = set(punctuation)
def task_func(text, filename):
"""
Save all words in a text beginning with the "$" character in a CSV file, excluding any words that are solely composed of punctuation characters.
Parameters:
text (str): The input text.
filename (str): The name of the CSV file to save the '$' words.
Returns:
str: The absolute path of the saved CSV file.
Note:
- The header of the csv row is "Word"
Requirements:
- nltk.tokenize.RegexpTokenizer
- string.punctuation
- csv
- os
Example:
>>> text = "$abc def $efg $hij klm $ $abc $abc $hij $hij"
>>> task_func(text, 'dollar_words.csv')
'/absolute/path/to/dollar_words.csv'
"""
instruct prompt
Save all words in a text beginning with the "$" character in a CSV file, excluding any words that are solely composed of punctuation characters.
Note that: The header of the csv row is "Word"
The function should output with:
str: The absolute path of the saved CSV file.
You should write self-contained code starting with:
Code
from nltk.tokenize import RegexpTokenizer
from string import punctuation
import csv
import os
PUNCTUATION = set(punctuation)
def task_func(text, filename):
code prompt
Code
from nltk.tokenize import RegexpTokenizer
from string import punctuation
import csv
import os
PUNCTUATION = set(punctuation)
def task_func(text, filename):
entry point
task_func
libs
- nltk
- csv
- string
- os
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