Build a concordance (aka “keyword in context”)

Goal

Build a concordance to examine the context of occurrence of a given query string.

Prerequisites

Some text has been imported in Orange Textable (see Cookbook: Text input) and possibly further processed (see Cookbook: Segmentation manipulation).

Ingredients

Widget

Segment

Context

Icon

segment_icon

context_icon

Quantity

1

1

Procedure

Widgets used to build a concordance and their interfaces

Figure 1: Widgets used build a concordance and their interfaces

  1. Create an instance of Segment and an instance of Context.

  2. Drag and drop from the output (righthand side) of the widget that emits the segmentation in which occurrences of the query string will be retrieved, here Text Field (Hamlet), to the input of Segment (lefthand side).

  3. Also connect both the Text Field and the Segment to Context (thus forming a triangle).

  4. Double-click on the icon of Segment to open its interface and type the query string in the Regex field (here: \btherefore\b); assign this instance of Segment a recognizable name, such as query.

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

  6. Double-click on the icon of Context to open its interface.

  7. In the Units section, select the segmentation that contains the occurrences of the query string (here: query) using the Segmentation drop-down menu.

  8. In the Contexts section, choose Mode: Containing segmentation and select the segmentation that contains the original text (here: Hamlet) using the Segmentation drop-down menu.

  9. Tick the Max. length checkbox and set the maximum number of characters that should be displayed on either side of each occurrence of the query string.

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

  11. A table showing the results is then available at the output of Context; to display or export it, see Cookbook: Table output.

Comment

  • In the Regex field of the Segment widget you can use all the syntax of Python’s regular expression (cf. Regular expressions); for instance, if you wish to restrict your search to entire words, you might frame the query string with word boundary anchors \b (in our example \btherefore\b).

See also