Friday 5 July 2013

Automatic user interface generation with CNL

There are many ways to automatically build and manage user interfaces. In this article we want to present a web application for automatic form generation that uses semantic knowledge description.
We believe that this solution is not only flexible but also highly understandable for non-technical users.

Fluent Editor  allows you to write rules for semantic forms with Controlled Natural Language (e.g. English CNL). User form in this example is built automatically based on knowledge base in CNL. Requirements for the form are written using modal expressions such as 'must', 'should' or 'can' e.g. 'Every patient must have-first-name ( some-string-value ).'

Ontology used to build user form in this example looks like below. This ontology is used by the web application to build a user form.

Every form is a thing.
patient-form is a form.
patient-form must concern a visit.

Comment: Visit.
Every visit must have-date (some-datetime-value ).
visit must have-health-center health-center.
Something is a health-center if-and-only-if-it is either Outpatients-Clinics-Of-Coi-Warsaw or Outpatients-Clinics-Of-Coi-Wroclaw.
Every visit must have-number ( some-integer-value ).
Every patient-form must concern patient.

 Comment: Patient.
Every patient must have-first-name  ( some-string-value ).
patient must have-last-name  ( some-string-value ).
patient must have-gender gender-type.
patient must have-age (some-integer-value ).
patient must have-birth-date (some-datetime-value).
is a gender-type if-and-only-if-it is either Male or Female.
patient that have-gender Female is a female-patient.
female-patient must have-maiden-name ( some-string-value ).
Every patient-form must concern an examination.

Every examination can have-observation observation.
Every radiological-assessment is an observation.
invasive-assessment is an observation.
Every ct is radiological-assessment. 
Every xray is radiological-assessment.
Every et is radiological-assessment.
Every biopsy is a invasive-assessment.
Every observation must have-date ( some-datetime-value ).
Every radiological-assessment must have-description nothing-but ( some-string-value).
Every ct must have-contrast-state yes-or-now-answer.
is a yes-or-now-answer if-and-only-if-it is either Yes-Answer or No-Answer.
Every biopsy must have-result pathological-assessment.
is a pathological-assessment if-and-only-if-it is either Gist-Confirmed or Retroperitoneal-Sarcoma or Other-Cancer.
Every examination that has-observation a biopsy that has-result Gist-Confirmed is a examination-with-sarcoma.
Every examination-with-sarcoma must concern a sarcoma.

 Comment: Sarcoma.
Every sarcoma must have-mass-localization a mass-localization-type .
sarcoma must have-diameter ( some-string-value ).
Every sarcoma must have-localization a localization.
sarcoma must have-surgical-state a surgical-state.
sarcoma must have-contradictions-state a contradictions-state.
sarcoma must have-patient-consent a yes-or-now-answer.

Something is a separation-state if-and-only-if-it is either Ruptured or Non-Ruptured.
is a surgical-state if-and-only-if-it is either Operable or Operable-With-Significant-Surgical-Morbidity or Non-Operable.
is a contradictions-state if-and-only-if-it is either No-Contradictions-For-Surgery or Contradictions-For-Surgery.
is a pathological-assessment if-and-only-if-it is either Gist-Confirmed or Retroperitoneal-Sarcoma or Other-Cancer.
is a mass-localization-type if-and-only-if-it is either Localized or Locally-Advanced or Metastatic.
is a localization if-and-only-if-it is either Stomach or Brain.

User form is represented by the concept form Patient-form is an instance of a form class. It requires some other information to be specified, such as patient details, examination details etc. Every dependent concept can also require some other data. Furthermore, we can build a hierarchy of concepts in CNL and it must be included in generated form. In this example observation, invasive assessment and radiological-assessment make a hierarchy of concepts.

Modifying  theform

We can modify the form at any time without making any changes to the source code of application. The ontology loaded by the application is the only place, where changes must be done. If new rules become valid, user form is refreshed and widgets are placed in the right place. For example, we can add two new rules to ontology.

Every patient must have-age (some-integer-value ).
Every patient must have-birth-date (some-datetime-value).

 After refreshing the form new widgets appear in the patient section.

MicroOntorion is used to perform queries and retrieve all valid requirements. When the user fills out the form and presses 'Submit' button, application verifies if all the rules are satisfied. Based on user input, new rules can be activated e.g. requirement 'Every female-patient must have-maiden-name (some-string-value).' is valid only for female patients. Application presents generated CNL knowledge, which can be used to infer new information about patient health and any further medical decisions.

If you want to learn more about Fluent Editor CNL-EN grammar, visit this link.

*) FluentEditor 2, 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 one from entering any sentence that is grammatically or morphologically incorrect and actively helps the user during sentence writing. The Controlled English is a subset of Standard English with restricted grammar and vocabulary in order to reduce the ambiguity and complexity inherent in full English.


  1. Actually Great. I’m also an expert in this topic so I can understand your hard work.
    An Emergency Protective Orderis a type of temporary court order issued in situations where there is an immediate threat of harm or danger to an individual.

  2. Queries are run using MicroOntorion to retrieve all requirements that are valid. Upon completing the form and clicking the "Submit" button, the application checks to see if all the requirements have been met. New rules can be triggered based on user input. For example, the requirement that "Every female patient must have a maiden name (some string value)" is only applicable to female patients.
    Fairfax DUI Third Offense