benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 8d115b2f-0cef-5773-89ba-c0546276d440

Problem

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

complete prompt

import os
from nltk import word_tokenize

def task_func(file_path='File.txt'):
    """
    Tokenizes a text file using the NLTK library. This function reads each line from the file, 
    breaks it into words or punctuation, and stores the tokens in a list.
    
    Parameters:
    - file_path (str): The path to the text file. Defaults to 'File.txt'.
    
    Returns:
    - list: A list of tokens.
    
    Requirements:
    - os
    - nltk.word_tokenize
    
    Examples:
    >>> task_func('sample.txt')
    ['Hello', ',', 'world', '!']
    >>> task_func('data.txt')
    ['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog', '.']
    """

instruct prompt

Tokenizes a text file using the NLTK library. This function reads each line from the file, breaks it into words or punctuation, and stores the tokens in a list.
The function should output with:
    list: A list of tokens.
You should write self-contained code starting with:

Code

import os
from nltk import word_tokenize
def task_func(file_path='File.txt'):

code prompt

Code

import os
from nltk import word_tokenize
def task_func(file_path='File.txt'):

entry point

task_func

libs

  • nltk
  • os

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