Include/exclude segments based on a pattern

Goal

Include or exclude segments from a segmentation using a regular expression

Prerequisites

Some text has been imported in Orange Textable (see Cookbook: Text input) and in all likelihood it has been segmented in smaller units (see Cookbook: Segment text in smaller units).

Ingredients

Widget

Select

Icon

select_icon

Quantity

1

Procedure

Include or exclude units based on a pattern with an instance of Select

Figure 1: Using the Select widget to include/exclude segments from a segmentation based on a regular expression

  1. Create an instance of Select.

  2. Drag and drop from the output (righthand side) of the widget that emits the segmentation to be filtered, here Segment (letters), to the input of Select (lefthand side).

  3. Double-click on the icon of Select to open its interface.

  4. In the Select section, choose either Mode: Include or Exclude.

  5. In the Regex field, insert the pattern that will select the units to be included or excluded, such as the single letter e in our example.

  6. Click the Send button or tick the Send automatically checkbox.

  7. A segmentation containing the selected segments is then available at the output of Select; to display or export it, see Cookbook: Text output.

Comment

  • In the Regex field you can use all the syntax of Python’s regular expression (cf. Regular expressions).

  • The Select widget emits on a second output connection (not selected by default) a segmentation containing the segments that were not selected (see Filtering segmentations using regexes for instructions on how to access this other output segmentation).

See also