From 3ce2172f7def7623d10716a7d1c7ff949973bdb7 Mon Sep 17 00:00:00 2001 From: fscelliott <42477011+fscelliott@users.noreply.github.com> Date: Wed, 29 Jan 2025 13:52:47 -0700 Subject: [PATCH] computedFieldGroup, pick_fields --- .../draft-sections-example-copy-to-section.md | 482 +++++++++++++++ .../0600 - draft-custom-computation-group.md | 583 +----------------- .../0500 - config-classification.md | 2 +- .../8000 - concepts/draft-pick-fields.md | 64 ++ 4 files changed, 561 insertions(+), 570 deletions(-) create mode 100644 readme-sync/v0/senseml-reference/6500 - sections/draft-sections-example-copy-to-section.md create mode 100644 readme-sync/v0/senseml-reference/8000 - concepts/draft-pick-fields.md diff --git a/readme-sync/v0/senseml-reference/6500 - sections/draft-sections-example-copy-to-section.md b/readme-sync/v0/senseml-reference/6500 - sections/draft-sections-example-copy-to-section.md new file mode 100644 index 000000000..eec555f87 --- /dev/null +++ b/readme-sync/v0/senseml-reference/6500 - sections/draft-sections-example-copy-to-section.md @@ -0,0 +1,482 @@ +--- +title: "Advanced: Transform sections data" +hidden: true + +--- + +The following example shows using computed fields to transform sections data. The example: + +- Copies a policy number and name from the parent `fields` array to each section using the Custom Computation method. The policy number and name are listed once in the document and are relevant to each extracted claim. To access the parent array's scope from inside each section, the method uses data-structure traversal syntax (`../../`). The example shows how to transform copied data, in this case by concatenating the copied fields. +- Redacts a telephone number. The example uses the Custom Computation method to replace digits in the number, and the Suppress Output method to omit the complete number from the output. + +**Config** + +```json +{ + "fields": [ + { + /* capture raw policy # to copy into + each claim */ + "id": "_raw_policy_number", + "type": "number", + "anchor": "policy number", + "method": { + "id": "label", + "position": "right" + } + }, + { + /* capture raw policy name to copy into + each claim */ + "id": "_raw_policy_name", + "anchor": "policy name", + "method": { + "id": "row", + } + }, + /* each claim starts with "claim number" and ends with + "Date of claim" */ + { + "id": "claims_sections", + "type": "sections", + "range": { + "anchor": { + "match": { + "type": "includes", + "text": "claim number" + }, + }, + "stop": { + "type": "includes", + "text": "Date of claim", + "isCaseSensitive": true + } + }, + /* return each claim as object containing claim # + and phone # fields */ + "fields": [ + { + "id": "claim_number", + "type": "number", + "anchor": { + "match": { + "type": "startsWith", + "text": "Claim number:", + "isCaseSensitive": true + } + }, + "method": { + "id": "label", + "position": "right" + } + }, + { + "id": "_raw_phone_number", + "type": "phoneNumber", + "anchor": { + "match": { + "type": "includes", + "text": "Phone number", + "isCaseSensitive": true + } + }, + "method": { + "id": "row", + "position": "right" + } + }, + /* **** TRANSFORM SECTION DATA ***** */ + /* OPTION 1: use `pick_fields` to copy fields into each section + then concatenate them */ + { + "method": { + /* output multiple fields with one jsonLogic rule */ + "id": "customComputationGroup", + "jsonLogic": { + /* copy the policy name and policy number from the parent `fields` + array into each section in the `claims_sections` array */ + "pick_fields": [ + { + /* source context for the fields is 1 level up in data hierarchy + so use traversal syntax, i.e. "../../.."*/ + "var": "../" + }, + [ + // the IDs of the fields to output into this section + "_raw_policy_number", + "_raw_policy_name" + ] + ] + } + } + }, + /* concatenate the fields copied into each section */ + { + "id": "policy_num_and_name_syntax_option_1", + "method": { + "id": "concat", + "delimiter": "_", + "source_ids": [ + "_raw_policy_number", + "_raw_policy_name" + ] + } + }, + /* OPTION 2: test traversal syntax with `log`, + then copy and concat fields' values into each section + */ + { + "id": "log_test", + "method": { + "id": "customComputation", + "jsonLogic": { + /* + print the value for ../_raw_policy_name as a field using the + "log" operator to ensure you're at the right traversal level + */ + "log": [ + "testing traversal for policy number w/ output as field", + { + "var": { + /* to evaluate tranversal syntax, + concatenate it first, + e.g., "cat" outputs + "../_raw_policy_name.value" */ + "cat": [ + "../", + "_raw_policy_number.value" + ] + } + } + ] + }, + } + }, + { + /* copy the policy name and policy number from the parent `fields` + array into each section in the `claims_sections` array, + and concatenate them w/ an underscore separator */ + "id": "policy_num_and_name_syntax_option_2", + "method": { + "id": "customComputation", + "jsonLogic": { + "cat": [ + { + /* print a log message and field value to Errors output + instead of fields output */ + "log": [ + "testing traversal for policy number, no field output", + { + "var": { + /* to evaluate tranversal syntax, + concatenate it first, + e.g., "cat" outputs + "../_raw_policy_number.value" */ + "cat": [ + "../", + "_raw_policy_number.value" + ] + } + }, + ] + }, + "_", + { + "var": { + "cat": [ + "../", + "_raw_policy_name.value" + ] + } + } + ] + } + } + }, + ], + "computed_fields": [ + /* redact the phone number using Custom Computation method's regex replace operation */ + { + "id": "redacted_phone_number", + "method": { + "id": "customComputation", + "jsonLogic": { + "replace": { + "source": { + "var": "_raw_phone_number.value" + }, + "find_regex": "^.*(\\d{4})$", + "replace": "***$1", + } + } + } + }, + { + "id": "cleanup", + "method": { + "id": "suppressOutput", + "source_ids": [ + "_raw_phone_number" + ] + } + } + ] + } + ] +} +``` + +**Example document** + +The following image shows the example document used with this example config: + +![Click to enlarge](https://raw.githubusercontent.com/sensible-hq/sensible-docs/main/readme-sync/assets/v0/images/final/copy_to_section.png) + +| Example document | [Download link](https://raw.githubusercontent.com/sensible-hq/sensible-docs/main/readme-sync/assets/v0/pdfs/sections.pdf) | +| ---------------------- | ------------------------------------------------------------ | + +**Output** + +```json +{ + "_raw_policy_number": { + "source": "5501234567", + "value": 5501234567, + "type": "number" + }, + "_raw_policy_name": { + "type": "string", + "value": "National Landscaping Solutions" + }, + "claims_sections": [ + { + "claim_number": { + "source": "1223456789", + "value": 1223456789, + "type": "number" + }, + "_raw_policy_number": { + "source": "5501234567", + "value": 5501234567, + "type": "number" + }, + "_raw_policy_name": { + "type": "string", + "value": "National Landscaping Solutions" + }, + "policy_num_and_name_syntax_option_1": { + "value": "5501234567_National Landscaping Solutions", + "type": "string" + }, + "log_test": { + "value": 5501234567, + "type": "number" + }, + "policy_num_and_name_syntax_option_2": { + "value": "5501234567_National Landscaping Solutions", + "type": "string" + }, + "redacted_phone_number": { + "value": "***8765", + "type": "string" + } + }, + { + "claim_number": { + "source": "9876543211", + "value": 9876543211, + "type": "number" + }, + "_raw_policy_number": { + "source": "5501234567", + "value": 5501234567, + "type": "number" + }, + "_raw_policy_name": { + "type": "string", + "value": "National Landscaping Solutions" + }, + "policy_num_and_name_syntax_option_1": { + "value": "5501234567_National Landscaping Solutions", + "type": "string" + }, + "log_test": { + "value": 5501234567, + "type": "number" + }, + "policy_num_and_name_syntax_option_2": { + "value": "5501234567_National Landscaping Solutions", + "type": "string" + }, + "redacted_phone_number": { + "value": "null", + "type": "string" + } + }, + { + "claim_number": { + "source": "6785439210", + "value": 6785439210, + "type": "number" + }, + "_raw_policy_number": { + "source": "5501234567", + "value": 5501234567, + "type": "number" + }, + "_raw_policy_name": { + "type": "string", + "value": "National Landscaping Solutions" + }, + "policy_num_and_name_syntax_option_1": { + "value": "5501234567_National Landscaping Solutions", + "type": "string" + }, + "log_test": { + "value": 5501234567, + "type": "number" + }, + "policy_num_and_name_syntax_option_2": { + "value": "5501234567_National Landscaping Solutions", + "type": "string" + }, + "redacted_phone_number": { + "value": "***8765", + "type": "string" + } + }, + { + "claim_number": { + "source": "7235439210", + "value": 7235439210, + "type": "number" + }, + "_raw_policy_number": { + "source": "5501234567", + "value": 5501234567, + "type": "number" + }, + "_raw_policy_name": { + "type": "string", + "value": "National Landscaping Solutions" + }, + "policy_num_and_name_syntax_option_1": { + "value": "5501234567_National Landscaping Solutions", + "type": "string" + }, + "log_test": { + "value": 5501234567, + "type": "number" + }, + "policy_num_and_name_syntax_option_2": { + "value": "5501234567_National Landscaping Solutions", + "type": "string" + }, + "redacted_phone_number": { + "value": "***8344", + "type": "string" + } + }, + { + "claim_number": { + "source": "8235439211", + "value": 8235439211, + "type": "number" + }, + "_raw_policy_number": { + "source": "5501234567", + "value": 5501234567, + "type": "number" + }, + "_raw_policy_name": { + "type": "string", + "value": "National Landscaping Solutions" + }, + "policy_num_and_name_syntax_option_1": { + "value": "5501234567_National Landscaping Solutions", + "type": "string" + }, + "log_test": { + "value": 5501234567, + "type": "number" + }, + "policy_num_and_name_syntax_option_2": { + "value": "5501234567_National Landscaping Solutions", + "type": "string" + }, + "redacted_phone_number": { + "value": "***9856", + "type": "string" + } + } + ] +} +``` + +And the `errors` output for the log operations is as follows: + +```json +[ + { + "type": "log", + "message": "testing traversal for policy number w/ output as field", + "result": "5501234567", + "field_id": "claims_sections.undefined" + }, + { + "type": "log", + "message": "testing traversal for policy number, no field output", + "result": "National Landscaping Solutions", + "field_id": "claims_sections.undefined" + }, + { + "type": "log", + "message": "testing traversal for policy number w/ output as field", + "result": "5501234567", + "field_id": "claims_sections.undefined" + }, + { + "type": "log", + "message": "testing traversal for policy number, no field output", + "result": "National Landscaping Solutions", + "field_id": "claims_sections.undefined" + }, + { + "type": "log", + "message": "testing traversal for policy number w/ output as field", + "result": "5501234567", + "field_id": "claims_sections.undefined" + }, + { + "type": "log", + "message": "testing traversal for policy number, no field output", + "result": "National Landscaping Solutions", + "field_id": "claims_sections.undefined" + }, + { + "type": "log", + "message": "testing traversal for policy number w/ output as field", + "result": "5501234567", + "field_id": "claims_sections.undefined" + }, + { + "type": "log", + "message": "testing traversal for policy number, no field output", + "result": "National Landscaping Solutions", + "field_id": "claims_sections.undefined" + }, + { + "type": "log", + "message": "testing traversal for policy number w/ output as field", + "result": "5501234567", + "field_id": "claims_sections.undefined" + }, + { + "type": "log", + "message": "testing traversal for policy number, no field output", + "result": "National Landscaping Solutions", + "field_id": "claims_sections.undefined" + } +] +``` + diff --git a/readme-sync/v0/senseml-reference/7500 - advanced-computed-field-methods/0600 - draft-custom-computation-group.md b/readme-sync/v0/senseml-reference/7500 - advanced-computed-field-methods/0600 - draft-custom-computation-group.md index 99dfe2dfc..95cb720da 100644 --- a/readme-sync/v0/senseml-reference/7500 - advanced-computed-field-methods/0600 - draft-custom-computation-group.md +++ b/readme-sync/v0/senseml-reference/7500 - advanced-computed-field-methods/0600 - draft-custom-computation-group.md @@ -3,7 +3,17 @@ title: "Custom computation group" hidden: true --- -Define your own [computed field method](doc:computed-field-methods) using [JsonLogic](doc:jsonlogic). For example, return the sum of two fields, map arrays, or return a boolean indicating if a field's output is non-null. +TODO before publish: + +- adjust wording for custom comp group ('returns a single field') +- add to the advanced-computed INDEX file +- search on links to doc:custom-computation + + + +Define your own [computed field method](doc:computed-field-methods) using [JsonLogic](doc:jsonlogic). Can return multiple fields. + + Parameters ==== @@ -13,575 +23,10 @@ The following parameters are in the computed field's [global Method](doc:compute | key | value | description | | :----------------------- | :-------------------------------- | :----------------------------------------------------------- | -| id (**required**) | `customComputation` | - This method has access to the `parsed_document` object at [verbosity](doc:verbosity) = 0.
- This method doesn't output [Sensible types](doc:types). It outputs `string, number, boolean, null` , or an array of those. For example, adding two currencies results in a number.
- This method returns null if you attempt to reference a variable that Sensible can't find in the `parsed_document`.
- This method returns null if calculations include a null. For example, `5 + null field = null`. If you instead want `5 + null field = 5`, then implement logic to replace nulls with zeros. For an example, see [Example 1](doc:custom-computation#example-1). | -| jsonLogic (**required**) | JsonLogic object | Transforms the output of one or more [Field objects](https://docs.sensible.so/docs/field-query-object) using [JsonLogic operations](doc:jsonlogic).
Double escape any dots in the field keys (for example, `delivery\\.zip\\.code`). Use dot notation to access arrays, for example, `test_table.columns.3.values` to access the 4th column in a table. | +| id (**required**) | `customComputationGroup` | - This method has access to the `parsed_document` object at [verbosity](doc:verbosity) = 0.
- This method doesn't output [Sensible types](doc:types). It outputs `string, number, boolean, null` , or an array of those. For example, adding two currencies results in a number.
- This method returns null if you attempt to reference a variable that Sensible can't find in the `parsed_document`.
- This method returns null if calculations include a null. For example, `5 + null field = null`. If you instead want `5 + null field = 5`, then implement logic to replace nulls with zeros. | +| jsonLogic (**required**) | JsonLogic object | Transforms the output of one or more [Field objects](https://docs.sensible.so/docs/field-query-object) using [JsonLogic operations](doc:jsonlogic). The output is one or more fields. TODO: update language in custom comp to specify 1 field
Double escape any dots in the field keys (for example, `delivery\\.zip\\.code`).
Use dot notation to access arrays, for example, `test_table.columns.3.values` to access the 4th column in a table. TODO: now we also have traversal syntax examples ... should this note go into the JsonLogic topic and get removed from here + other topics? probably! maybe as a tip? INCLUDE the descriptions too in the json logic topic?
| Examples ==== -## Example 1 - -The following example shows defining custom computed fields. - -**Config** - -```json -{ - "fields": [ - { - "method": { - "id": "queryGroup", - "queries": [ - { - "id": "prop_limit_a", - "description": "property damage limit in first table (insurer A)", - "type": "currency" - }, - { - "id": "injury_limit_a", - "description": "bodily injury limit in first table (insurer A)", - "type": "currency" - }, - { - "id": "vehicle_vin_a", - "description": "vehicle vin for insurer A", - "type": "number" - } - ] - } - }, - { - "id": "table_b", - "method": { - "id": "nlpTable", - "description": "table for insurer B describing insurance limits", - "columns": [ - { - "id": "make_and_model", - "description": "make and model", - "type": "string" - }, - { - "id": "vehicle_vin", - "description": "vehicle vin", - "type": "string" - }, - { - "id": "policy_effective_date", - "description": "policy effective date", - "type": "string" - }, - { - "id": "limits", - "description": "limits", - "type": "string" - }, - { - "id": "dollar_amount_per_limit", - "description": "dollar amount per limit", - "type": "string" - } - ] - } - }, - ], - "computed_fields": [ - /* check an extracted field is non-null */ - { - "id": "prop_limit_exists", - "method": { - "id": "customComputation", - "jsonLogic": { - "exists": [ - { - "var": "prop_limit_a.value" - } - ] - } - } - }, - /* check a field's value matches a regex */ - { - "id": "injury_limit_matches_regex", - "method": { - "id": "customComputation", - "jsonLogic": { - "match": [ - { - "var": "injury_limit_a.value" - }, - "^\\w+$" - ] - } - } - }, - /* redact the vehicle's VIN using regex replace operation */ - { - "id": "replace_regex", - "method": { - "id": "customComputation", - "jsonLogic": { - "replace": { - "source": { - "var": "vehicle_vin_a.value" - }, - "find_regex": "(\\d{4})(\\d{4})", - "replace": "xxxx$2", - "flags": "g" - } - } - } - }, - /* modify value using JsonLogic in replace operation */ - { - "id": "replace_var", - "method": { - "id": "customComputation", - "jsonLogic": { - "replace": { - "source": { - "var": "injury_limit_a.value" - }, - "find": { - "var": "injury_limit_a.value" - }, - "replace": { - "+": [ - { - "var": "prop_limit_a.value" - }, - 200 - ] - } - } - } - } - }, - /* perform addition on an extracted field's value */ - { - "id": "prop_limit_addition", - "method": { - "id": "customComputation", - "jsonLogic": { - "+": [ - { - /* check that prop_limit_a.value is non-null - if it's null, replace it with zero. - otherwise the operation returns null */ - "if": [ - { - "var": "prop_limit_a.value" - }, - { - "var": "prop_limit_a.value" - }, - 0 - ] - }, - 200 - ] - } - } - }, - { - /* modify a table's column using map */ - "id": "map_table", - "method": { - "id": "customComputation", - "jsonLogic": { - /* perform map operation on each limit in the 'limits' column */ - "map": [ - { - /* the array to be mapped: the fourth column, titled "limits", in a table - / Note Sensible uses dot notation to access array elements, - for example, insurer_b_table.columns.3.values - */ - "var": "table_b.columns.3.values" - }, - { - /* Note it's "cat" for strings, "+" for numbers */ - "cat": [ - { - "var": "value" - }, - // append the word "LIMIT" to each limit description - " LIMIT" - ] - } - ] - } - } - }, - ] -} -``` - -**Example document** -The following image shows the example document used with this example config: - -![Click to enlarge](https://raw.githubusercontent.com/sensible-hq/sensible-docs/main/readme-sync/assets/v0/images/final/add_computed_fields_1.png) - -| Example document | [Download link](https://raw.githubusercontent.com/sensible-hq/sensible-docs/main/readme-sync/assets/v0/pdfs/add_computed_fields.pdf) | -| ---------------- | ------------------------------------------------------------ | - -**Output** - -```json -{ - "prop_limit_a": { - "source": "$5,000", - "value": 5000, - "unit": "$", - "type": "currency" - }, - "injury_limit_a": { - "source": "$3,000", - "value": 3000, - "unit": "$", - "type": "currency" - }, - "vehicle_vin_a": { - "source": "12345678", - "value": 12345678, - "type": "number" - }, - "table_b": { - "columns": [ - { - "id": "make_and_model", - "values": [ - { - "value": "Honda Accord", - "type": "string" - }, - { - "value": "Honda Accord", - "type": "string" - }, - { - "value": "Honda Accord", - "type": "string" - } - ] - }, - { - "id": "vehicle_vin", - "values": [ - { - "value": "92343156", - "type": "string" - }, - { - "value": "92343156", - "type": "string" - }, - { - "value": "92343156", - "type": "string" - } - ] - }, - { - "id": "policy_effective_date", - "values": [ - { - "value": "12/19/20", - "type": "string" - }, - { - "value": "12/19/20", - "type": "string" - }, - { - "value": "12/19/20", - "type": "string" - } - ] - }, - { - "id": "limits", - "values": [ - { - "value": "Property damage*", - "type": "string" - }, - { - "value": "Bodily injury**", - "type": "string" - }, - { - "value": "Auto only*", - "type": "string" - } - ] - }, - { - "id": "dollar_amount_per_limit", - "values": [ - { - "value": "$6,000", - "type": "string" - }, - { - "value": "$4,000", - "type": "string" - }, - { - "value": "$1,000", - "type": "string" - } - ] - } - ], - "title": { - "type": "string", - "value": "Insurer B" - }, - "footer": { - "type": "string", - "value": "* per person ** per accident" - } - }, - "prop_limit_exists": { - "value": true, - "type": "boolean" - }, - "injury_limit_matches_regex": { - "value": true, - "type": "boolean" - }, - "replace_regex": { - "value": "xxxx5678", - "type": "string" - }, - "replace_var": { - "value": "5200", - "type": "string" - }, - "prop_limit_addition": { - "value": 5200, - "type": "number" - }, - "map_table": [ - { - "value": "Property damage* LIMIT", - "type": "string" - }, - { - "value": "Bodily injury** LIMIT", - "type": "string" - }, - { - "value": "Auto only* LIMIT", - "type": "string" - } - ] -} -``` - -## Example 2 - -The following example shows using the Custom Computation method to perform the following operations on data extracted from an claims loss run insurance document: - -- Get the total number of claims listed in the document - -- Redact the claim IDs - -- Sum up the incurred cost for all claims listed - -**Config** - -```json -{ - "fields": [ - { - /* use sections to extract repeating data, - in this case, claims */ - "id": "claims_sections", - "type": "sections", - "range": { - /* starting line of each claim is "claim number" */ - "anchor": "claim id", - /* ending line of each claim is "incurred" */ - "stop": "incurred" - }, - "fields": [ - { - "id": "raw_claim_id", - "anchor": "claim id", - "method": { - /* target data to extract is a single line - to right of anchor line ("claim number") */ - "id": "label", - "position": "right" - } - }, - { - "id": "incurred_amount", - "type": "currency", - "anchor": "incurred", - "method": { - /* target data to extract is a single line - to right of anchor line ("incurred") */ - "id": "label", - "position": "right", - } - }, - { - "id": "redacted_id", - "method": { - /* use JsonLogic to perform custom - data transformation */ - "id": "customComputation", - "jsonLogic": { - /* the Replace method extends jsonLogic - to enable regex find/replace operations */ - "replace": { - "source": { - /* replace 1st 3 digits in each ID with '***' - to redact it */ - "var": "raw_claim_id.value" - }, - "find_regex": ".*(\\d{3})(\\d{7}).*", - "replace": "***$2", - } - } - } - }, - /* hide unredacted IDs from output */ - { - "id": "hide_fields", - "method": { - "id": "suppressOutput", - "source_ids": [ - "raw_claim_id" - ] - } - } - ], - }, - ], - "computed_fields": [ - { - /* output the number of claims in the document - by taking the length of the claims array */ - "id": "claim_count", - "method": { - "id": "customComputation", - "jsonLogic": { - "var": "claims_sections.length" - } - } - }, - /* get the sum of all incurred dollar - amounts in the document */ - { - "id": "total_incurred", - "method": { - "id": "customComputation", - "jsonLogic": - /* for each incurred_amount value, - add it to a running total sum - Note: this syntax is an alternative to the Reduce operation */ - { - "+": { - "map": [ - { - "var": "claims_sections" - }, - { - "var": "incurred_amount.value" - } - ] - } - } - } - }, - ] -} -``` - -**Example document** -The following image shows the example document used with this example config: - -![Click to enlarge](https://raw.githubusercontent.com/sensible-hq/sensible-docs/main/readme-sync/assets/v0/images/final/blog_custom_computations.png) - -| Example document | [Download link](https://raw.githubusercontent.com/sensible-hq/sensible-docs/main/readme-sync/assets/v0/pdfs/blog_custom_computations.pdf) | -| ---------------- | ------------------------------------------------------------ | - -**Output** - -```json -{ - "claims_sections": [ - { - "incurred_amount": { - "source": "$3,053", - "value": 3053, - "unit": "$", - "type": "currency" - }, - "redacted_id": { - "value": "***3456789", - "type": "string" - } - }, - { - "incurred_amount": { - "source": "$251", - "value": 251, - "unit": "$", - "type": "currency" - }, - "redacted_id": { - "value": "***6543211", - "type": "string" - } - }, - { - "incurred_amount": { - "source": "$985", - "value": 985, - "unit": "$", - "type": "currency" - }, - "redacted_id": { - "value": "***5439210", - "type": "string" - } - }, - { - "incurred_amount": { - "source": "$581", - "value": 581, - "unit": "$", - "type": "currency" - }, - "redacted_id": { - "value": "***5439210", - "type": "string" - } - }, - { - "incurred_amount": { - "source": "$771", - "value": 771, - "unit": "$", - "type": "currency" - }, - "redacted_id": { - "value": "***5439211", - "type": "string" - } - } - ], - "claim_count": { - "value": 5, - "type": "number" - }, - "total_incurred": { - "value": 5641, - "type": "number" - } -} -``` +See [Advanced: Transform sections data](doc:sections-example-copy-to-section). diff --git a/readme-sync/v0/senseml-reference/8000 - concepts/0500 - config-classification.md b/readme-sync/v0/senseml-reference/8000 - concepts/0500 - config-classification.md index 8f1d85dbc..9afce5eab 100644 --- a/readme-sync/v0/senseml-reference/8000 - concepts/0500 - config-classification.md +++ b/readme-sync/v0/senseml-reference/8000 - concepts/0500 - config-classification.md @@ -5,7 +5,7 @@ hidden: true Sensible supports two levels of document classification: -1. Classify a document by its similarity to each document type you define in your Sensible account. +1. Classify a document by its similarity to the document types you define in your Sensible account. 2. Classify a document by its subtype, or "config", during the extraction workflow. This topic covers classifying a document by its subtype. You can configure the defaults for how this step is performed. diff --git a/readme-sync/v0/senseml-reference/8000 - concepts/draft-pick-fields.md b/readme-sync/v0/senseml-reference/8000 - concepts/draft-pick-fields.md new file mode 100644 index 000000000..9ef40c659 --- /dev/null +++ b/readme-sync/v0/senseml-reference/8000 - concepts/draft-pick-fields.md @@ -0,0 +1,64 @@ +--- +title: "pick fields draft" +hidden: true +--- + +Returns the specified fields. Takes an array of two items: + +- an object to get fields from +- an array of field IDs to pick + +```json +{ + "pick_fields": [ + { sourceContext }, + ["field_id_1", "field_id_2", "field_id_3"] + ] +} +``` + +returns an empty object if: + +- you pass an empty array as the second argument, or if Sensible can't find the specified field IDs +- if the source is empty, null, or undefined + +### Examples + +#### Example 1 + +As a simplified example, if you apply the rule: + +```json +{ + "pick_fields": [ + // `"var": ""` returns the current context, in this case, a fields array + // you can use traversal syntax to access other levels of data hierarchy, i.e., "var:" "../.." + { "var": "" }, + // the IDs of the fields to copy into this context + ["field_morning", "field_afternoon"] + ] +} +``` + +to the following extracted fields: + +```json +{ + "field_morning": "good morning", + "field_afternoon": "good afternoon", + "field_evening": "good evening" +} +``` + +then the Pick Fields operator outputs: + +```json +{ + "field_morning": "good morning", + "field_afternoon": "good afternoon" +} +``` + +#### Example 2 + +For a complete example, see [Advanced: Transform sections data](doc:sections-example-copy-to-section).