Skip to content

segment property

result.match_info.rules.segment is an array containing the results of segmentation.
Each array item has the following properties:

Property Description
name Segment name
instances Segment instances

instances is an array. Its items have the following properties:

Property Description
begin Starting position of the textual scope where the instance was found
end Ending position of the textual scope where the instance was found
score Instance score
rules Segmentation rules that have been triggered

rules is an array. Its items have the following properties:

Property Description
id Internal ID of the segmentation rule
label Segmentation rule label
scope Segmentation rule scope

scope is an array. Its items have the following properties:

Property Description
begin Starting position of the textual scope where the segment was found
end Ending position of the textual scope where the segment was found
operands Segmentation rule operands

operands is an array. Its items have the following properties:

Property Description
operand Internal ID of the segmentation rule operand
begin Starting position of the textual scope where the operand was found
end Ending position of the textual scope where the operand was found

For example, considering these segments:

SEGMENTS
{
    @JOB_AND_COMPANY_JOHN_DOE,
    @JOB_AND_COMPANY_JANE_DOE
}

and these segmentation rules:

SCOPE SENTENCE
{
    SEGMENT(JOB_AND_COMPANY_JOHN_DOE)
    {
        LEMMA("developer")
        <1:4>
        TYPE(COM)
    }

    SEGMENT(JOB_AND_COMPANY_JANE_DOE)
    {
        LEMMA("technical writer")
        <1:4>
        TYPE(COM)
    }
}

applied to this text:

John Doe was born on the 15th of June 1995, he lives in 17 Johns Street and he works as a developer for expert.ai.
Jane Doe was born on the 16th of June 1995, she lives in 18 Miller Street and she works as a technical writer for expert.ai.

the segment property has the following JSON serialization:

"segment": [
        {
          "name": "JOB_AND_COMPANY_JANE_DOE",
          "instances": [
            {
              "begin": 115,
              "end": 237,
              "score": 10,
              "rules": [
                {
                  "id": 5,
                  "label": "",
                  "scope": [
                    {
                      "begin": 115,
                      "end": 237,
                      "operands": [
                        [
                          {
                            "operand": 5,
                            "begin": 207,
                            "end": 222
                          },
                          {
                            "operand": 5,
                            "begin": 228,
                            "end": 236
                          }
                        ]
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "JOB_AND_COMPANY_JOHN_DOE",
          "instances": [
            {
              "begin": 0,
              "end": 113,
              "score": 10,
              "rules": [
                {
                  "id": 4,
                  "label": "",
                  "scope": [
                    {
                      "begin": 0,
                      "end": 113,
                      "operands": [
                        [
                          {
                            "operand": 4,
                            "begin": 90,
                            "end": 98
                          },
                          {
                            "operand": 4,
                            "begin": 104,
                            "end": 112
                          }
                        ]
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]