Categorize texts containing specific keywords with custom labels.
Assigns each text to one or more categories. Each category is defined by a list of keywords a text must include or exclude to be labelled accordingly. In addition, each category may specify whether a keyword must be matched explicitly, ignoring its case (lower, upper) etc. See parameters below for further details.
The following example shows how the step can be used in a recipe.
Examples
The following defines the keywords to be included or exluded for each of three categories, labelled “journalist”, “business” and “CEO”. Note how in the case of “CEO” we’re looking for occurrences of the spelling with capitals only.
The following are the inputs expected by the step and the outputs it produces. These are generally
columns (ds.first_name
), datasets (ds
or ds[["first_name", "last_name"]]
) or models (referenced
by name e.g. "churn-clf"
).
Inputs
A text column to label.
Outputs
A column containing the labels assigned to each text.
The following parameters can be used to configure the behaviour of the step by including them in
a json object as the last “input” to the step, i.e. step(..., {"param": "value", ...}) -> (output)
.
Parameters
One or more named text categories. Each parameter should be a key indicating the name/label to show for a specific text category, and should have an object as value specifying the terms a text must or must not contain for that particular label to apply. Also see examples above.
Properties
List of strings a text must include to apply a label.
Array items
Each item in array.
List of strings a text must not include to apply a label.
Array items
Each item in array.
Whether to make search accent-sensitive.
Whether to make search case-sensitive.
Whether to match whole words only. If enabled, only matches a word if it is surrounded by non-alphanumeric characters.