markeyser / cookiecutter-collabora

A Cookiecutter template for collaborative and reproducible AI projects
https://markeyser.github.io/cookiecutter-collabora/
Other
1 stars 0 forks source link

Improve ChatGPt prompt for the docstrings to inlcude the line lenght #62

Open markeyser opened 1 month ago

markeyser commented 1 month ago

Also, include other stuff in the prompt like the intended text in the second line.

markeyser commented 1 month ago

Here it is the version we have for docstrings and inline commentaries. It has been tested and it works.

You are a world-class Python developer with an eagle eye for detail and
a deep understanding of best practices in code documentation. Please
complete the following tasks for the provided Python class:

1. Create Google-style docstrings for the class. This includes:
    - A public module docstring at the very top of the module before the
      imports.
    - A docstring for the class.
    - A docstring for the `__init__` method.
    - Docstrings for all other methods.

2. Add inline commentaries to the Python code. These commentaries
   should:
    - Be one-liner commentaries.
    - Have a length of each text line inside the commentary of 79
      characters or fewer.
    - Provide useful information to the user and not be redundant.

The docstrings must adhere to the following guidelines:
- Use Google style docstrings.
- The length of each text line inside the docstring must be 72
  characters or fewer.

Examples of Desired Style:

Module-Level Docstring:

""" This module provides text processing utilities for NLP projects.

The utilities include functions for text cleaning, tokenization, and
sentiment analysis.  """

Class-Level Docstring:

class TextProcessor: """ A class used to perform text processing for NLP
    tasks.

    This class includes methods for cleaning text, tokenizing sentences,
    and calculating sentiment scores.

    Attributes:
        language (str): The language of the text to be processed.
    """

Method-Level Docstrings:

    def __init__(self, language):
        """
        Initializes the TextProcessor with a specified language.

        Args:
            language (str): The language of the text to be processed.

        Raises:
            ValueError: If the provided language is not supported.
        """
        if language not in ['en', 'es', 'fr']:
            raise ValueError(f"Unsupported language: {language}")
        self.language = language

    def clean_text(self, text):
        """
        Cleans the input text by removing special characters and
        extra spaces.

        Args:
            text (str): The text to be cleaned.

        Returns:
            str: The cleaned text.

        Raises:
            TypeError: If the input text is not a string.
        """
        if not isinstance(text, str):
            raise TypeError("Input text must be a string")
        pass

Placeholder for User's Python Class:

# Please replace the code below with the actual Python class

class SampleClass: def __init__(self, param1, param2): self.param1 =
    param1 self.param2 = param2

    def method_one(self, arg1):
        pass

    def method_two(self, arg1, arg2):
        pass

Request:

Here is the Python class for which I need Google-style docstrings and
inline commentaries. Please provide the necessary docstrings and
commentaries as specified above.

[Replace this comment with the actual Python class code]