Skip to content

Add Context Features

You can add context features either by choosing from suggested features when there is a conflict or by defining your own. A context feature is a way to compose a new feature from existing features to detect lexical patterns or indicate the existence or lack of existence of one feature given the other. The two features that compose the context feature could be any combination of dictionary features only, context features only or a combination of a dictionary and a context.

  1. When you create a new context feature, give your feature a name and select the schema entity that the feature would associate with. You can select multiple schema entities.

  2. Select the two underlying features that compose the context feature.

  3. Scroll down to "Context Type Options" to specify how the two underlying features are related. Duet supports the following 6 options for composing two features in a context feature, which we'll demonstrate with examples relating to a US address extractor, where we will use the concept of "states", the concept of "zip" and a variety of tokens in-between.
    a. Precedes: the feature triggers if both underlying features (e.g. states, zip) are present with a predefined amount of tokens in-between them. This is ideal for identifying phrases in which the order of tokens is important. Such context features will capture something like "Washington, 98108", where the comma is a token that separates the state and the zip.The feature will file on the three tokens "Washington", "," and "98108".
    b. Precedes 1: This is the same as the Precedes option but the feature will fire only on the token that belongs to feature 1. In the example, "Washington, 98108", the context feature will fire only on the word "Washington".
    b. Precedes 2: This is the same as the Precedes option but the feature will fire only on the token that belongs to feature 2. In the example, "Washington, 98108", the context feature will fire only on the word "98108".
    d. Or: the feature triggers if either of the underlying features (e.g. "states" or "zip") is present in the document. Word order doesn't matter.
    e. If: this is a conditional feature that will trigger on the first feature if the second feature is present in the document.
    f. If not: this is a conditional feature that will trigger on the first feature if the second feature is not present in the document.

  4. The "Feature Matching Options" tab enables you to specify the position of the feature with respect to the entity it is associated with. There are six options.
    a. "Inside" means the feature fires if one of its phrases exist within the boundary of the entity segment.
    b. "Exact match" means the feature fires if one of its phrases exactly matches the entity segment.
    c. "Begins" means the feature fires if one of its phrases takes place at the beginning of the entity segment.
    d. "Ends" means the feature fires if one of its phrases takes place at the end of the entity segment.
    e. "Follows" means the feature fires if one of its phrases exactly follows the entity segment.
    f. "Precedes" means the feature fires if one of its phrases exactly precedes the entity segment.

  5. Once finished, press "Add New" at the bottom of the screen.

You can check your progress by looking at the quality metric with every model update. When you obtain the quality that you are looking for, you should stop teaching and move onto testing for entity extractors.

Back to top