Working with Pattern Based Functions
Pattern based functions facilitate the application designer's work.
With pattern based functions you can create string based functions by only providing input and output examples instead of writing script code. For example you can transform email addresses to names like john.doe@sap.com to John Doe.
-
In the Outline of your application, add a ScriptObject.
-
Choose
(More Actions) beside the script object and
select Add Pattern Based Function. This opens
the Pattern Based Function dialog where you can
see the generated name of the functio and where you can add a
description for the function.
-
By clicking the
symbol next to Create Pattern you can add an
input and output example. Under Training Example
you can define that a certain input shall become a certain output (for
example john.doe@sap.com shall become
John Doe) . NoteSometimes one example is not enough due to potential ambiguity. In this case you can use up to three training examples by clicking the
symbol for each following
example. -
Click Create so that a machine learning algorithm starts looking for a pattern that matches every example.
Note-
As soon as you change a Training Example the pattern will fall back to default which is just returning the input.
-
If you want to undo your changes on new or modified training examples, Reset which will set the pattern based function to the last working pattern with the according training examples.
-
-
If the pattern creation has been successful you can verify the pattern by entering input examples that follow your pattern above; otherwise it will keep it's default pattern which is just outputting the input. To verify the pattern click the
symbol next to
Verify Pattern.. Type a test example.under
Input to test the
Output: In the output field you should see
the correct output that follows your output pattern above. -
When you've finished your work, click Done.
If you have successfully created a pattern based function and its pattern, you can use it in
every script of the application just like any other script object function. The
following example shows how the pattern based function is used in a script of the
application: 
Let's assume you have a list of dates in the form of month.day.year for example 10.11.2011 and you want to change this to 11.10.11. So you type 10.11.2011 as input and 11.10.11 as output in the Training Example section.
In this example you switch the day and the month and only take the last two digits of the year. But since this is not unambiguously (it is not clear if the number 11 at the end is taken from the month or the last digits of the year) you need to provide a second training example like 09.05.2020 as input example and 05.09.20.as output example.
If you have for example a list of appointments like this John Doe has an appointment on 06.07.20 at 3:00pm. you could transform this into Name: John Doe, Date: 06.07.20, Time: 3:00pm.
So you type John Doe has an appointment on 06.07.20 at 3:00pm. as input and Name: John Doe, Date: 06.07.20, Time: 3:00pm as output in the Training Example section.