Sensible

The Sensible Developer Hub

Welcome to the Sensible developer hub. You'll find comprehensive guides and documentation to help you start working with Sensible as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Return text or lines proximate to the anchor point. This method is sensitive to font sizes and line spacing.

Unlike many other methods (such as Document Range), the Label method can return data that is in the same line as the anchor line. You can do so by specifying position: left or position: right in the Label method.

Parameters

Note: For the full list of parameters available for this method, see Global parameters for methods. The following table only shows parameters most relevant to or specific to this method.

KeyValueDescription
id (required)label
position (required)above, below, left, rightWhat direction the target data is relative to the anchor point. For horizontal matching ("position": "left" or "position": "right"), this method returns the remainder of the anchor line. For example, if the anchor line is
"Comprehensive premium: $500"
and the Match object is
{ "type": "includes", "text": "premium: " }
The Label method returns "$500".
stopfirst, gap, or a Match object. default: firstUse with "position": "below".
Specifies to grab multiple lines following a label, rather than the default first line. When you specify this parameter, this method matches the first line in the specified position relative to the anchor, and then continues down the page until it meets the specified stop.  SenseML does not include the line that matches the Stop parameter in the output.
Only matches lines that are aligned on a y-axis to the left boundary of the first matching line, unless you define a different alignment method using  the Text Alignment parameter. The match does not include lines that are positioned to the left or right of matching lines.
For gap , this method stops when it reaches a vertical gap of 0.2 inches between line boundaries, and for a Match object, this method stops when it reaches a matching line.
textAlignmentleft, right, or hangingIndent. default: left.Only applies to "position": "below" or "position": "above".
Determines whether to match lines aligned on an y-axis along either the left or right boundaries of the anchor line. 
hangingIndent only applies to "position": "below".  The anchor's and the first indented line's boundaries must be within 0.3 inches of each other. There are no restrictions in inches for the indent.
includeAnchorboolean. default: falseWhether to include the anchor text in the output. For example, if you specify a single line using the Starts With and Ends With parameters in a match array in the anchor,  SenseML returns null unless you set this parameter to true.

Examples

The following image shows examples of various labels in the Sensible app:

You can try out this example yourself in the Sensible app using the following downloadable PDF and config:

Example PDF for label methodDownload link

This example uses the following config:

{
  "fields": [
    {
      "id": "simple_label",
      "anchor": "Here is a good candidate",
      "method": {
        "id": "label",
        "position": "below"
      }
    },
    {
      "id": "one_line_label",
      "anchor": {
        "match": [
          {
            "type": "startsWith",
            "text": "A label can be in one line:"
          }
        ]
      },
      "method": {
        "id": "label",
        "position": "right",
        "wordFilters": [
          "but filter out this extra text"
        ]
      }
    },
    {
      "id": "hanging_indent_label",
      "anchor": "Here is the first line of a hanging indent",
      "method": {
        "id": "label",
        "position": "below",
        "textAlignment": "hangingIndent",
        "stop": "gap"
      }
    },
    {
      "id": "only_looks_like_a_label",
      "anchor": "This also looks",
      "method": {
        "id": "label",
        "position": "below",
      }
    },
    {
      "id": "doc_range_alternative",
      "anchor": "This also looks",
      "method": {
        "id": "documentRange",
        "stop": {
          "text": "to work",
          "type": "startsWith"
        }
      }
    },
  ]
}

The preceding example shows fields that do the following:

  1. The simple_label field grabs a line below a label.
  2. The one_line_label field grabs text to the right of a label on the same line, and filters out an unwanted string.
  3. The hanging_indent_label field grabs multiple lines of text by using a Stop parameter. The method grabs indented lines ("textAlignment": "hangingIndent") , and the match does not include lines to the left or right of matching aligned lines. For example, in the PDF, the line "But lines to the left or right aren't matched" is ignored, because it isn't aligned on a y-axis with other matching lines.
  4. The only_looks_like_a_label field demonstrates that labels are sensitive to font size differences by returning null.
  5. The doc_range_alternative fields shows an alternate way to grab the line targeted by only_looks_like_a_label.

Updated 11 days ago


Label


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.