Stop word filter

Updated at:

This topic describes the Stop Word Filter component available in Designer.

Use this component to remove stop words—common, high-frequency words with little semantic weight, such as "the", "is", or "a"—from word tokenization results.

The Stop Word Filter component requires two inputs: an input table containing the text to be filtered, and a single-column stop word table where each row is a stop word.

You can configure the Stop Word Filter component's parameters using the Designer visual interface or a PAI command.

Component configuration

Configure the Stop Word Filter component using one of the following methods.

Method 1: Visual interface

Configure the component parameters on the Designer pipeline page.

Tab

Parameter

Description

field settings

columns to filter

Specifies the columns to filter. To specify multiple columns, separate the column names with a comma (,).

tuning

cores

By default, the system automatically allocates resources.

memory size

By default, the system automatically allocates resources.

Method 2: PAI command

Configure the component's parameters with a PAI command. You can run PAI commands using the SQL Script component. For more information, see SQL Script.

PAI -name FilterNoise -project algo_public \
    -DinputTableName=”test_input” -DnoiseTableName=”noise_input” \
    -DoutputTableName=”test_output” \
    -DselectedColNames=”words_seg1,words_seg2” \
    -Dlifecycle=30

Parameter

Required

Description

Default

inputTableName

Yes

The name of the input table that contains the tokenized text.

None

inputTablePartitions

No

The input table partitions to use.

All partitions

noiseTableName

Yes

The name of the stop word table.

None

noiseTablePartitions

No

The stop word table partitions to use.

All partitions

outputTableName

Yes

The name of the output table.

None

selectedColNames

Yes

The columns to filter. To specify multiple columns, separate the column names with a comma (,).

None

lifecycle

No

The lifecycle of the output table in days. The value must be a positive integer.

None

coreNum

No

The number of cores for the job.

System-allocated

memSizePerCore

No

The memory size per core.

System-allocated

Example

  • Input data

    • The sample input table, temp_word_seg_input, contains three columns: doc_idx (document index), s_idx (sentence index), and seg (tokenized text segment). The sample data includes five segments from Document 1 and three segments from Document 2. The seg column contains the tokenized Chinese text.

    • The following is an example of the temp_word_noise_input stop word table. This table contains a noise_word column that lists stop word entries, including 在, 地, 时, 他, 是, 比如, 而是, 的, 《, 》, ,, ?, and 也.

  • Create a pipeline创建实验

  • Select the columns to filter

    Select the seg column to filter.

  • Execution result: The output table contains three columns: doc_idx (document index), s_idx (sentence index), and seg (tokenized text segment). Each row corresponds to a sentence in a document. The seg column contains the tokenized Chinese text with stop words removed, with words separated by spaces.