Create Pattern-Based Functions

As an application designer or story developer, you can use pattern-based functions in analytic applications or optimized stories to facilitate your work by only providing input and output examples instead of writing scripts.

Context

With pattern-based functions you can define how a certain input shall become a certain output. For example, john.doe@sap.com shall become John Doe.

After creating a script object, you can add a pattern-based function to it by providing such input and output training examples.

Procedure

  1. In the Outline panel select next to a scripting object and then Add Pattern-Based Function.

    You can see that the Pattern-Based Function panel opens and a new function is displayed under the script object in Outline.

  2. You can change the name of the pattern-based function and add description.
  3. Select next to Create Pattern.
  4. Under Training Example you can provide an input-to-output example.
    Note

    Sometimes one training example might not be enough due to potential ambiguity. In this case you can use up to three. You may find the example below.

  5. Select Create so that a machine learning algorithm starts looking for a pattern that matches every example.
    Note

    If you want to undo your changes on a training example, select Reset, which will set the pattern-based function to the last working pattern with the according training examples.

  6. Verify the pattern by entering test examples. Select next to Verify Pattern, and enter an input. In the output field you should see the right output that follows the pattern defined.
  7. After the pattern-based function's been successfully created, select Done.

    You can use it in every script of the application or story just like any other script object functions:

Example: Transform Dates

Assume you have a list of dates in the form of month.day.year, for example, 10.11.2011, and you want to switch day and month and only take the last two digits of the year. You type 10.11.2011 as input and 11.10.11 as output in the Training Example section.

However, the example is a bit ambigous as it is not clear whether 11 at the end means month or year. You need to provide a second training example like 09.05.2020 as input and 05.09.20 as output.

If you have a list of appointments, for example, John Doe has an appointment on 06.07.20 at 3:00pm. and you'd like to transform this into Name: John Doe, Date: 06.07.20, Time: 3:00pm, you can directly type them as input and output respectively.