You need to enable JavaScript to run this app.
Lake AI Service

Lake AI Service

Copy page
Download PDF
Text processing
Copyright statement removal
Copy page
Download PDF
Copyright statement removal

Operator introduction

Description

Copyright statement remover - removes text related to copyright statements from the content

Key features

  • Copyright statement detection: Automatically identifies copyright statement comments in code
  • Intelligent cleanup: Precisely removes content based on copyright statement characteristics
  • Multi-format support: Supports block comment and line comment formats

Application scenarios

  • Code copyright statement cleanup
  • Text preprocessing and standardization
  • Code quality inspection and optimization

Technical features

  • Supports two copyright statement formats:
    • Block comment format: /* ... Comment blocks within */ that contain the copyright keyword
    • Line comment format: Line comments starting with //, #, or --

Daft invocation

Operator parameters

Input

Input column name

Note

texts

Column of text to be processed; element type must be string

Output

Column of cleaned text, with copyright statement-related content removed

Examples

The following code demonstrates how to use daft to run the operator and remove copyright statement content from text.

from __future__ import annotations

import os

import daft
from daft import col
from daft.las.functions.text.copyright_cleaner import CopyrightCleaner
from daft.las.functions.udf import las_udf

if __name__ == "__main__":

    if os.getenv("DAFT_RUNNER", "native") == "ray":
        import logging

        import ray

        def configure_logging():
            logging.basicConfig(
                level=logging.INFO,
                format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
                datefmt="%Y-%m-%d %H:%M:%S.%s".format(),
            )
            logging.getLogger("tracing.span").setLevel(logging.WARNING)
            logging.getLogger("daft_io.stats").setLevel(logging.WARNING)
            logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING)

        ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging})
        daft.set_runner_ray()
    daft.set_execution_config(actor_udf_ready_timeout=600)
    daft.set_execution_config(min_cpu_per_task=0)

    samples = {
        "text": [
            "/* \n * Copyright (c) 2023 Jane Smith\n * \n */ ",
            
        ]
    }

    ds = daft.from_pydict(samples)
    ds = ds.with_column(
        "cleaned_text",
        las_udf(
            CopyrightCleaner,
            construct_args={},
        )(col("text")),
    )

    ds.show()
    # ╭──────────────────────────────────────────────┬──────────────────────────────────────────────╮
    # │ text                                         ┆ cleaned_text                                │
    # │ ---                                          ┆ ---                                          │
    # │ Utf8                                         ┆ Utf8                                         │
    # ╞══════════════════════════════════════════════╪══════════════════════════════════════════════╡
    # │ /* 
 * Copyright (c) 2023 Jane Smith
 * 本    ┆  你好                                        │
    # │ 代码依据 Apache License 2.0 授权,详见随附的     ┆                                             │
    # │ LICENSE 文件。 */ 你好                        ┆                                             │
    # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
    # │ # 版权 (c) 2023 Jane Smith
# 本代码依据 Apache    ┆  你好                                        │
    # │ License 2.0 授权,详见随附的 LICENSE 文件。 \n     ┆                                             │
    # │ 你好                                          ┆                                             │
    # ╰──────────────────────────────────────────────┴──────────────────────────────────────────────╯
Last updated: 2026.05.22 11:17:46