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

Lake AI Service

Copy page
Download PDF
Text processing
Remove text links
Copy page
Download PDF
Remove text links

Operator introduction

Description

Hyperlink removal operator - text link regex replacement

Key features

  • Identify common forms of hyperlinks such as protocol links, www links, domain + path, and more.
  • Replace matched hyperlinks with the specified string (repl). The default replacement is "".
  • Batch process strings. For exceptions, return None.

Technical implementation

  • Regex matching: the default built-in expression is semantically equivalent to the LAS version.
  • Compatible with input strings wrapped in r'...' / r"..." format (removes the r prefix and quotes).
  • Precompile the regex and enable DOTALL semantics to cover multi-line text.
  • Logging: outputs the default or custom regex and processing statistics for troubleshooting.

Daft invocation

Operator parameters

Input

Input column name

Description

texts

Array of strings, each element is a text string.

Output

Array of processed strings. For exceptions, return None.

Parameters

If a parameter does not have a default value, it is required.

Parameter name

Type

Default value

Description

pattern

str

Regex for locating hyperlinks. If empty, the operator's built-in expression is used. Compatible with input wrapped in r'...' or r"..." format.

repl

str

The string used to replace matched hyperlinks. Defaults to an empty string.

Examples

The following code demonstrates how to use Daft to run the operator to remove links from text.

from __future__ import annotations

import logging
import os

import ray

import daft
from daft import col
from daft.las.functions.text.remove_links import RemoveLinks
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": [
            "prefix https://example.com/path suffix",
            None,
        ]
    }

    pattern = ""
    repl = "[LINK]"

    ds = daft.from_pydict(samples)

    ds = ds.with_column(
        "cleaned_text",
        las_udf(
            RemoveLinks,
            construct_args={"pattern": pattern, "repl": repl},
        )(col("text")),
    )
    ds.show()

    # ╭────────────────────────────────┬──────────────────────╮
    # │ text                           ┆ cleaned_text         │
    # │ ---                            ┆ ---                  │
    # │ Utf8                           ┆ Utf8                 │
    # ╞════════════════════════════════╪══════════════════════╡
    # │ prefix https://example.com/pa… ┆ prefix [LINK] suffix │
    # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
    # │ None                           ┆ None                 │
    # ╰────────────────────────────────┴──────────────────────╯
Last updated: 2026.05.12 19:06:37