22 August 2022
less than a minute read
Our declarative modeling language Rel has been expanded to include new string functionalities to better handle and manipulate string data.
Two new string literal forms are now supported: raw string literals and interpolation expressions inside string literals.
Raw string literals are string literals that keep their contents verbatim.
This allows users to provide complex strings (for example, for regular expressions) without any extra steps. No processing is applied and there is no need to escape special characters.
Complex strings are denoted by the
raw identifier, immediately followed by some amount of odd quotes. The same amount of quotes must be used to terminate the literal. Anything in between is taken as is.
Special characters can appear without escaping, and escaping a character simply means two characters (
\ and the escaped character). Any number of quotes that are less than the delimiting quotes can appear inside the literal.
Some examples are below.
The empty string. Note that this is the only form allowed for empty strings. Using more quotes results in a parser error:
Using quotes without escaping:
raw"""say, "hello" now"""
No need to use triple quotes for multiline strings:
raw"this is a multi line text "
Leading spaces are not discarded (as would be the case in “normal” string literals):
raw" Hello And bye "
Using multiple quotes inside the string:
raw"""""many """"quotes here"""""
Rel also now supports the arbitrary interpolation of expressions inside string literals.
The operator used for interpolation is
%. As such, if the actual percent character is needed instead, it has to be escaped (or alternatively, be used in a raw string literal).
The result of the interpolation is a string, so arbitrary “nesting” is allowed too, as shown in the examples below.
Alternative to using
raw"100% success rate":
"100\% success rate"
Interpolating values from an expression:
def names = "Alice"; "Bob" def output = "hello %(names)"
If the interpolated expression is a single variable, parentheses are optional:
def output = "hello %names"
The outer string literal is interpolating an expression that itself is using string interpolation:
def from_id = ("user_1", "Alice"); ("user_2", "Bob") def ids = 1;2;3 def output = "hello %(from_id["user_%ids"]) and bye"
We’re excited to learn about how you are using Rel – please let us know about any future features you’d like to see.
We are excited to announce the RelationalAI Command-Line Interface, which is used to interact with the Relational Knowledge Graph Management System (RKGMS).Read More
RelationalAI is built on knowledge graphs, which rarely use null and boolean values. And yet, Rel, RelationAI’s declarative modeling language, has a Missing data type to represent null values, and a Bool type to represent true and false boolean values. Let's explore the role null and boolean values play in a dataset and learn when to use Missing and Bool types in Rel.Read More
We are excited to announce the latest enhancements to our Relational Knowledge Graph Management System (RKGMS) that substantially improve the performance of certain recursive computations.Read More