Keywords

Learn about the basic keywords in Kognitos, their usage, and examples.

1. the Keyword

Introduces a new object, concept, or data element.

Example

In this example, we are introducing a file to Kognitos.

the file

2. get Keyword

Used to retrieve objects or to obtain values from a document.

Example

In these examples, we are first retrieving a document, and then retrieving the id and date values from the document.

get the document
get the document's "id"
get the document's "date"

3. find Keyword

Used to search for and obtain details from a document.

Example

Here, we are searching for a document's date and invoice number.

find the document's "date"
find the document's "invoice number"

The difference between get and find

Both get and find can be used to obtain information from a document:

get the document's phone number
find the document's phone number

The difference between the two is how they handle exceptions when a specified item is not found in the document:

  • The get keyword raises a Question and pauses execution.
  • The find keyword returns Not Found and continues execution.
get versus find

4. use Keyword

The use keyword specifies an item to act upon in a given context or process.

use the email address

It can also redirect the system to take an existing item and use it for further actions or assignments.

In this example, this system is instructed to use the email address as the contact email for any subsequent processing steps.

use the email address as the contact email

5. say Keyword

Outputs the value of a data element or text.

Examples

📝 Example 1
say "Hello World!"
📖 Result

Hello World!

📝 Example 2
say the name
📖 Result

John Smith

6. stop Keyword

Halts a run or process from progressing further.

Example

say "Hello!"
stop
say "Goodbye!"

In this example, say "Goodbye!" will not run.

7. imagine Keyword

The imagine keyword is used to declare a data element as a placeholder.

Example

imagine a value
imagine templates

8. set Keyword

Assigns a specific value to a variable.

Example

set the name to "John Smith"

9. remove Keyword

Used to delete specified elements, such as characters, words, or items, from a variable or dataset.

Example

remove punctuation from the text

10. convert Keyword

Transforms data from one format to another.

Example

convert the file to a gif file

11. add Keyword

The add keyword is used to combine, extend, or append data to an existing set or structure. This includes both mathematical addition and data aggregation in various formats.

Arithmetic Addition

Used to add two numerical values to produce a single sum.

add 10 and 5

Date and Time Addition

Used to add a specified time duration to a given date.

the date is "2024-11-01"
add two days to the date

Data Aggregation

Used to expand datasets by adding new items, rows, or entries.

add a column to the table
add the invoice as a row in the worksheet

12. contains Keyword

Used to check if a string, list, or dataset includes a specific value.

Example 1: Strings

In this example, contains is used to check if the surname Smith is present in the full name John Smith.

the full name is "John Smith"
if the full name contains "Smith" then
	say "The surname is correct!"

Result:

The surname is correct!

Example 2: Sets

In this example, contains is used to check if oranges is present in the set of values.

the values are "apples", "bananas", "oranges"
if the values contain "oranges" then
	say "The oranges are available."

Result:

The oranges are available.

Example 3: Tables

The contains keyword can be used with tables to retrieve rows whose columns include a specific value.

Example Table

Consider the following table that lists various zoo animals, their ages, and their favorite foods.

AnimalAnimal AgeFavorite Food
🦁 Lion7 yearsMeat
🐘 Elephant10 yearsFruits
🦓 Zebra3 yearsGrass
🦒 Giraffe7 yearsLeaves
🐒 Monkey4 yearsFruits

The contains keyword is used to retrieve the rows where the Favorite Food column includes the value Fruits.

get the table's rows whose Favorite Food contains "Fruits"
Result
AnimalAnimal AgeFavorite Food
🐘 Elephant10 yearsFruits
🐒 Monkey4 yearsFruits

13. ask Keyword

The ask keyword is used to ask a question to the user. The question will be raised as a custom exception. Additionally, you can specify answers as a set of choices.

Examples

ask "What is your age?"
ask "The access code"
ask "When does the flight depart?"
  the choices are "Morning", "Afternoon", "Evening"
ask "preferred language"
  the choices are "English", "Spanish", "Hindi"