Key-Value Pair (Collation Provider): Difference between revisions

From Grooper Wiki
Line 43: Line 43:
<tab name="Create a Data Type" style="margin:20px">
<tab name="Create a Data Type" style="margin:20px">
=== Create a Data Type ===
=== Create a Data Type ===
'''Data Type''' extractors use Collation Providers to combine, filter, or otherwise manipulate extraction results.  Collation Providers are set using the '''Data Type's''' '''''Collation''''' property.
{|cellpadding=10 cellspacing=5
|style="width:40%" valign=top|
So, the very first thing to do is create a '''Data Type'''.  Here, we are creating the '''Data Type''' in the '''Local Resources''' folder of a '''Content Model'''.
# Right-click the location where you are adding the '''Data Type''', here the '''Local Resources''' folder.
# Mouse over "Add" and select "Data Type".
# Name the '''Data Type'''.  Here we are naming it "KVP - Home Phone"
#* ''Visit the [[Asset Management]] article for our best practices guide to naming your extractors.''
# Press the "OK" button to create it.
|
[[File:Key-Value Pair - Grooper Screenshots 01.png]]
|}
</tab>
</tab>
<tab name="Create the Key Extractor" style="margin:20px">
<tab name="Create the Key Extractor" style="margin:20px">
=== Create the Key Extractor ===
=== Create the Key Extractor ===
'''Key-Value Pair''' extractors must have exactly two extractors, a "Key Extractor" and a "Value Extractor".  The "Value Extractor" is ultimately the value the '''Key-Value Pair''' returns.  The "Key Extractor" is how you find the value.  It's result will be used as a positional anchor to find the value.  Our goal with the document seen here is to differentiate between the various "home phone" numbers from the "cell phone" numbers.  So, our key extractor simply needs to find the label, "home phone".
{|cellpadding=10 cellspacing=5
|style="width:40%" valign=top|
# Add the "Key Extractor" to the '''Data Type'''.
#* Here, we've added a child '''Data Format''' to the '''Data Type''' and named it "KEY".  However, the "Key Extractor" could also be a child '''Data Type''', a referenced extractor, even the parent '''Data Type's''' internal '''''Pattern'''''.
# Configure the "Key Extractor" to return the key result you're looking for.
#* Here, we're looking for the label "home phone".  We simply type "home phone" as the value pattern.
# Notice, we are getting three results.  That's ok!  The ''Key-Value Pair'' collation settings will help us narrow down the result ultimately returned.
|
[[File:Key-Value Pair - Grooper Screenshots 02.png]]
|}
</tab>
</tab>
<tab name="Create the Value Extractor" style="margin:20px">
<tab name="Create the Value Extractor" style="margin:20px">

Revision as of 13:57, 26 August 2020

Key-Value Pair is a Collation Provider for Data Type extractors. It uses the layout relationship between a key and a value on a document to return a result.

Key-Value Pair collation is one of the most commonly used Collation Providers. It provides an excellent way to extract data when a value exists next to a label on a document, whether next to it horizontally, vertically, or even in a "right-to-left & top-to-bottom" text flow.


About

The Key-Value Pair Collation Provider utilizes the spatial relationship between two related extractor results to return a single result, typically looking for a piece of data (the value) next to a label (the key).

For structured documents, it is common for a piece of data to be identified by some sort of label, usually to the left of it, or above it.

In these images, the field label, highlighted in blue, identifies the field's value, highlighted in yellow. We use this kind of labeling relationship to identify data on documents all the time. The Key-Value Pair Collation Provider is perfectly suited to use these labeling relationships.

Key-Value Pair collated Data Types (often just referred to as Key-Value Pairs) collate the results of two extractors, a "key extractor" and a "value extractor". The "key extractor" will locate the label (or whatever context is being used to return the data you want). The "value extractor" will return all possible values matching the data you want to return.

Once collated, the Key-Value Pair will return the closest value to the key, according to the assigned Layout Settings (The top image uses a Horizontal Layout because the labels are aligned next to each other horizontally. The bottom uses a Vertical Layout).

Key-Value Pair collation also has applications in unstructured document processing. Unstructured documents convey information in paragraphs and sentences more than they do with structured fields. Because of this, the value may not be horizontally or vertically aligned, but somewhere before or after a labeling key in the text flow.

For these situations, the Flow Layout can be used, which will use the relationship between the key and the value in the text data's right-to-left and top-to bottom text flow.

A Key-Value Pair could be build to extract the driver name (highlighted here in yellow), using the phrase "driver's name" in the text flow before it.

How To

Create A Key-Value Pair Extractor

Create a Data Type

Data Type extractors use Collation Providers to combine, filter, or otherwise manipulate extraction results. Collation Providers are set using the Data Type's Collation property.

So, the very first thing to do is create a Data Type. Here, we are creating the Data Type in the Local Resources folder of a Content Model.

  1. Right-click the location where you are adding the Data Type, here the Local Resources folder.
  2. Mouse over "Add" and select "Data Type".
  3. Name the Data Type. Here we are naming it "KVP - Home Phone"
    • Visit the Asset Management article for our best practices guide to naming your extractors.
  4. Press the "OK" button to create it.

Create the Key Extractor

Key-Value Pair extractors must have exactly two extractors, a "Key Extractor" and a "Value Extractor". The "Value Extractor" is ultimately the value the Key-Value Pair returns. The "Key Extractor" is how you find the value. It's result will be used as a positional anchor to find the value. Our goal with the document seen here is to differentiate between the various "home phone" numbers from the "cell phone" numbers. So, our key extractor simply needs to find the label, "home phone".

  1. Add the "Key Extractor" to the Data Type.
    • Here, we've added a child Data Format to the Data Type and named it "KEY". However, the "Key Extractor" could also be a child Data Type, a referenced extractor, even the parent Data Type's internal Pattern.
  2. Configure the "Key Extractor" to return the key result you're looking for.
    • Here, we're looking for the label "home phone". We simply type "home phone" as the value pattern.
  3. Notice, we are getting three results. That's ok! The Key-Value Pair collation settings will help us narrow down the result ultimately returned.

Create the Value Extractor

Set the Collation Provider

Configure the Layout Settings