Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datajuicer Data juicer TextActionFilter

From Leeroopedia
Knowledge Sources
Domains Data_Quality, Filtering
Last Updated 2026-02-14 16:00 GMT

Overview

Concrete tool for filtering data samples based on action verb count provided by Data-Juicer.

Description

TextActionFilter is a filter operator that keeps samples containing at least a minimum number of action verbs. It extends Filter and uses the two-phase compute_stats/process pattern. It uses a spaCy NLP model (supporting English and Chinese) to parse text and identify action verbs by checking both POS tags (VERB) and specific fine-grained tags (VV, VB, VBP, VBZ, VBD, VBG, VBN). The count is cached under num_action in the sample stats. Useful for filtering datasets for narrative or instructional content where the presence of actions indicates dynamic, descriptive text.

Usage

Import when filtering based on action verb count. Configure in YAML or Python.

Code Reference

Source Location

Signature

@OPERATORS.register_module("text_action_filter")
class TextActionFilter(Filter):
    def __init__(self, lang: str = "en", min_action_num: int = 1, *args, **kwargs):

Import

from data_juicer.ops.filter.text_action_filter import TextActionFilter

I/O Contract

Inputs

Name Type Required Description
lang str No Language for action detection: "en" or "zh" (default: "en")
min_action_num int No Minimum number of actions to keep sample (default: 1)

Outputs

Name Type Description
samples Dict Filtered samples with num_action stat computed

Usage Examples

YAML Configuration

process:
  - text_action_filter:
      lang: en
      min_action_num: 1

Python API

from data_juicer.ops.filter.text_action_filter import TextActionFilter
op = TextActionFilter(lang="en", min_action_num=1)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment