Friday, 16 January 2015

Using the rOntorion package in R / RStudio and Fluent Editor

The rOntorion package is the port of Cognitum's Semantic Technologies to R. R has become an important tool among Statisticians and Data Scientists and we are proud to provide this community with an enhanced Linked-Data manipulation experience that will allow them to edit, store and reason over structured data (in the supported formats ocnl, rdf and owl); henceforth discovering new horizons in Data Analysis. rOntorion allows to extend Fluent Editor in R and in turn provides the users with the capability of creating their own custom functionality.

rOntorion in R

To demonstrate the use of rOntorion directly from R, let us go through a minimal example. In this example we are going to reason over a set of dummy sentences and infer a single logical conclusion by querying the semantic engine with a question expressed in ocnl format. First we need to install rOntorion: to do so, issue the following command in an R Console:

> options(repos = c(CRAN='', COGNITUM=''))

Now you can install rOntorion using the install.packages R function:

 > install.packages("rOntorion", NULL, repos = getOption("repos"), type="source")

Once rOntorion is properly installed, create a new script in R with the following content:
str <- paste("If a mouse likes a cat then the mouse greets the cat.",
           "Kitty is a cat.", 
           "Mickey is mouse.", 
           "Mickey likes Kitty.", sep="\n")
onto<-ontorion.load.cnl.string(str, FALSE) 
ontorion.instances.of(onto,"something that greets a cat")
#Result: [1] "Mickey"
You can learn more about the grammar used in this example at CNL Grammar. For your convenience, you can navigate the help contents of rOntorion in RStudio.

Alternatively you can use the "help(rOntorion)" command in an R console after loading the rOntorion library.

rOntorion in Fluent Editor

Fluent Editor ships with 2 built-in R plugins. This plugins are found under the Tools ribbon:

To assess the value of the provided functionality, let us go through a couple of examples. In Fluent Editor, open the "African WildLife" template by clicking in File → African Wildlife. Once the ontology is loaded, click on the "Draw Ontology Graph". After clicking, the Fluent Editor visual interface will mutate to the state shown below:

The R Output window will display any textual results from the computation and the status icon in the status bar of Fluent Editor will show the state of the R engine computation. In this moment the request is being performed asynchronously. Once the results of the computation are ready, a graph will be displayed:

This graph outlines the different relationships among entities in the ontology. For the demonstration of the second plugin, click on the "Enumerate Universe" icon; this plugin provides a textual enumeration of concepts and instances in the ontology, including a description of all instances that features the list of the concepts from which each instance inherits its properties. This plugin is also a sample of R editing functionality as shown in the screenshot below where the plugin has added a comment (hightlighted in red) to the current editor:

If you want to learn more about Fluent Editor 2014 R2, visit this link.

*) FluentEditor 2014 R2, ontology editor, is a comprehensive tool for editing and manipulating complex ontologies that uses Controlled Natural Language. Fluent editor provides one with a more suitable for human users alternative to XML-based OWL editors. It's main feature is the usage of Controlled English as a knowledge modeling language. Supported via Predictive Editor, it prohibits user from entering any sentence that is grammatically or morphologically incorrect and actively helps the user during sentence writing. 


  1. Unable to load the rOntorion library. Here are my results after running install.packages:

    > install.packages("rOntorion", NULL, repos = getOption("repos"), type="source")
    Warning in install.packages :
    cannot open: HTTP status was '404 The specified blob does not exist.'
    Warning in install.packages :
    cannot open: HTTP status was '404 The specified blob does not exist.'
    Warning in install.packages :
    unable to access index for repository
    trying URL ''
    Content type 'application/x-gzip' length 40767985 bytes (38.9 Mb)
    opened URL
    downloaded 38.9 Mb

    * installing *source* package ‘rOntorion’ ...
    ** R
    ** inst
    ** preparing package for lazy loading
    ** help
    Warning: /private/var/folders/_6/zzjtvp4d6jb1ynhmp2b775wh0000gn/T/RtmpRBfHtL/R.INSTALL104621ce2181/rOntorion/man/ontorion.load.cnl.file.Rd:20: unknown macro '\item'
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded
    Error : .onLoad failed in loadNamespace() for 'rOntorion', details:
    call: NULL
    error: package ‘rClr’ was built for x86_64-w64-mingw32
    Error: loading failed
    Execution halted
    ERROR: loading failed
    * removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rOntorion’
    Warning in install.packages :
    installation of package ‘rOntorion’ had non-zero exit status

    The downloaded source packages are in

  2. Hi Chip,

    Unfortunately, we are not supporting OSX yet. Please stay tuned, since we are working on a viable port.

  3. I am staying tuned looking forward to the port.

  4. any update on supporting OSX? Just the package, I can bare to use the editor in a virtual box - thx