benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf bae02c05-4d7b-5fd6-8b11-6f5b4775c63e

Problem

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

complete prompt

import re
import glob
from docx import Document


def task_func(directory_path: str) -> int:
    """
    Processes all Word (.docx) files in the provided directory, searching for double quotes in the text 
    and adding a backslash before each double quote to "protect" it.
    
    Parameters:
    - directory_path (str): Path to the directory containing .docx files to be processed.
    
    Returns:
    - int: Number of .docx files processed.

    Requirements:
    - re
    - docx
    - glob

    Example:
    >>> import tempfile
    >>> temp_dir = tempfile.mkdtemp()
    >>> doc = Document()
    >>> _ = doc.add_paragraph("This is a sample text with double quotes.")
    >>> doc.save(temp_dir + '/sample.docx')
    >>> task_func(temp_dir)
    1
    """

instruct prompt

Processes all Word (.docx) files in the provided directory, searching for double quotes in the text and adding a backslash before each double quote to "protect" it.
The function should output with:
    int: Number of .docx files processed.
You should write self-contained code starting with:

Code

import re
import glob
from docx import Document
def task_func(directory_path: str) -> int:

code prompt

Code

import re
import glob
from docx import Document
def task_func(directory_path: str) -> int:

entry point

task_func

libs

  • glob
  • docx
  • 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