vignettes/construct_expressions.Rmd
construct_expressions.Rmd
The Cortical API requires semantic expression to be written in a format that is not native to R. This document shows the general procedure to construct semantic expressions in R. For more information, check the Cortical documentation
Take a look at the following two examples from the Cortical documentation:
{
"term" : "apple"
}
and
{
"sub" : [
{
"term" : "apple"
},
{
"text" : "Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems."
}
]
}
This looks (and is) a bit complicated, but in general, the rules are like this:
exp <- list(
"term" = "apple"
)
exp <- list(
# Named operator
"sub" = list( # ... whose value is a list
list("term" = "apple"), # ... each element has its own list.
list("text" = "Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems.")
)
)
exp <- list(
# Each element is an unname list
list(
"term" = "apple"
),
# Second element
list(
"sub" = list(
list("term" = "apple"),
list("text" = "Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems.")
)
)
)