.. _section-KB Editor for Content Browsing: KB Editor for Content Browsing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The **KB Editor** plugin allows users to browse classes, subclasses and individual instances of the ontology base or KB. It also allows classes, individual instances and instance properties in the KB to be edited, added and removed. This section describes the browing capabilities of the **KB Editor**. For its editing capabilities, please refer to Section :ref:`section-KB Editor for Content Editing`. **Launching the KB Editor** Double click a .flr ontology file in the **Sunflower** project navigation window. This loads the ontology file into the **Text Editor**. Activate the **KB Editor** plugin by selecting **Window -> Show View -> KB Editor** from the main navigation toolbar, or by directly clicking the **KB Editor** tab across the middle of the right window, as illustrated in :numref:`figure-KB-Editor-show-view.png` and :numref:`figure-KB-Editor-Tab.png`. .. _figure-KB-Editor-show-view.png: .. figure:: ../../figs/KB-Editor-show-view.png :alt: Show View -> KB Editor Show View -> KB Editor .. _figure-KB-Editor-Tab.png: .. figure:: ../../figs/KB-Editor-Tab.png :alt: KB Editor Tab across middle of **Sunflower**’s right window KB Editor Tab across middle of **Sunflower**’s right window **Taxonomy Window in KB Editor** The **KB Editor** displays the KB in a taxonomy tree which includes 4 main categories of information: **Classes**, **Latent Queries**, **Queries** and **Rules**. There is also an uncategorized category to catch identifiers which fall outside of the known categories. Subclass and individual identifiers are displayed hierarchically under the category **Classes**. In the **KB Editor** taxonomy window, identifiers in **bold black** are individual instances or classes local to the current file. Identifiers in gray are identifiers which are non-local or imported. Identifiers in **bold gray** are non-local identifiers which have a local subclass or a local instance, e.g., **Test**. :numref:`figure-KB-Editor-Family.png` shows the taxonomy window when it is first launched with family.flr loaded in the **Text Editor**. .. _figure-KB-Editor-Family.png: .. figure:: ../../figs/KB-Editor-Family.png :alt: Initial view of family.flr in **KB Editor** taxonomy window Initial view of family.flr in **KB Editor** taxonomy window By default, the **KB Editor** taxonomy tree includes all local and non-local identifiers in the import closure. Local identifiers appear in bold black while non-local identifiers appear in gray. The tab across the top to the right of the taxonomy window shows the default option **All**. Click this tab and a drop-down menu with one other option should appear, as shown in :numref:`figure-KB-Editor-All-menu.png`. The other option **Relevant** retricts the taxonomy tree to show only local identifiers from the current file. .. _figure-KB-Editor-All-menu.png: .. figure:: ../../figs/KB-Editor-All-menu.png :alt: The **All, Relevant** menu in KB Editor The **All, Relevant** menu in KB Editor The **Tree Expansion** setting sets the expansion level of the entire taxonomy tree. Only the top level of the taxonomy tree is shown when this setting is 1. The top and 2nd levels are shown when the setting is 2, and so on. In :numref:`figure-KB-Editor-expansion.png`, the top 3 levels of family.flr are shown after **Tree Expansion** is set to 3. .. _figure-KB-Editor-expansion.png: .. figure:: ../../figs/KB-Editor-expansion.png :alt: **Tree Expansion** is set to 3 and the top 3 levels of the taxonomy tree are displayed **Tree Expansion** is set to 3 and the top 3 levels of the taxonomy tree are displayed **Editing Window of KB Editor** To the right of the taxonomy window is the editing window of the **KB Editor**. Detail information of the currently selected identifier in the taxonomy window is shown here in 4 tables: **Superclasses**, **Class Properties**, **Types** and **Individual Properties**. Depending on the type of identifier selected, some of the tables may be empty. :numref:`figure-KB-Editor-2-windows.png` shows this editing window with detail information about the selected identifier **Person**. The following describes how to use the **KB Editor** to inspect or browse the KB. To use the **KB Editor** for editing the KB, see section :ref:`section-KB Editor for Content Editing` for more details. .. _figure-KB-Editor-2-windows.png: .. figure:: ../../figs/KB-Editor-2-windows.png :alt: Details of the selected identifier **Person** are shown in the **KB Editor** editing window Details of the selected identifier **Person** are shown in the **KB Editor** editing window To launch the editing window, simply click to highlight an identifier in the taxonomy window. For example, click to select class identifier **Person**. As illustrated in :numref:`figure-KB-Editor-Person.png`, an empty **Superclass** table is shown because **Person** has no superclass. The **Types** and **Individual Properties** tables are also empty because **Person** has no individual content. The **Class Properties** table, on the other hand, shows a list of properties for **Person**. Each property is displayed with columns including **Property** name, **Value**, **Kind**, **Min**, **Max**, **Asserted In**, and **File**. The **Value** column is the property’s data type or default class, **Kind** is the type of value such as range or value, **Min** and **Max** are the minimum cardinality required and maximum cardinality allowed respectively, **Asserted In** is the class or individual instance where the property value or range is asserted, and **File** is the name of the file where the property is asserted. .. _figure-KB-Editor-Person.png: .. figure:: ../../figs/KB-Editor-Person.png :alt: **Class Properties** table for identifier **Person** **Class Properties** table for identifier **Person** **Browsing a Class Identifier in the Editing Window** A class identifier such as **Person** is an identifier with class content. For a class identifier, a property in **black** indicates that it is directly asserted in that class, while a property in **gray** indicates that it is inherited from a parent class. Note that :numref:`figure-KB-Editor-Person.png` shows all properties of class identifier **Person** in **black**. This is because all these properties are directly asserted in the **Person** class. Click the > or expand button next to **Person** in the taxonomy window to see the subclasses **Man**, **MotherInLaw** and **Woman**. Then click class identifier **Man** to see all its properties shown in **gray**, as shown in :numref:`figure-KB-Editor-Man-inferred-on.png`, which indicates they are all inherited from **Man**’s parent class **Person**. Also note that because **Man** is a subclass of **Person**, its **Superclasses** table contains the entry **Person**. .. _figure-KB-Editor-Man-inferred-on.png: .. figure:: ../../figs/KB-Editor-Man-inferred-on.png :alt: **Superclasses** and **Class Properties** tables for identifier **Man** **Superclasses** and **Class Properties** tables for identifier **Man** **Browsing an Individual Identifier in the Editing Window** An individual identifier has individual content such as types or individual properties. In the taxonomy window, click the > or expand button next to **Man** to show a list of individuals of this class. Then click individual **Eric** to see the **Individual Properties** table in the editing window, as shown in :numref:`figure-KB-Editor-Eric.png`. Among the properties shown are Eric’s birthDate, Eric’s spouse, etc. Also shown in the editing window is the **Types** table containing direct and indirect superclasses which **Eric** is an individual instance of. .. _figure-KB-Editor-Eric.png: .. figure:: ../../figs/KB-Editor-Eric.png :alt: Properties of individual instance **Eric** Properties of individual instance **Eric** **Browsing with Hyperlinks in the Editing Window** **Blue** color links in the editing window, e.g. **Person** in :numref:`figure-KB-Editor-Eric.png`, are hyperlinks. When clicked, the hyperlink is put into focus. It becomes highlighted in the taxonomy window, and the editing windows shows the details of the hyperlink. After clicking a hyperlink, the **backward** button located at the top of the taxonomy window, as shown in :numref:`figure-KB-Editor-forward-backward-refresh.png`, can be used to return to the previous view. The **KB Editor** keeps a history of current identifiers, and the **backward** and **forward** buttons are convenient tools to re-establish previous browsing context. There is also a **Refresh** button to clear browsing history. Since this button automatically recomputes and redraws the taxonomy tree, it is handy to have for refreshing the taxonomy view. .. _figure-KB-Editor-forward-backward-refresh.png: .. figure:: ../../figs/KB-Editor-forward-backward-refresh.png :alt: **Backward** and **Foreward** buttons for undo and repeat, **Refresh** button for start afresh **Backward** and **Foreward** buttons for undo and repeat, **Refresh** button for start afresh **Browsing with and without Inferred Properties** The **Inferred** option in the **KB Editor**, when checked, shows properties in the editing window whether or not they are editable. On the other hand, when this option is unchecked, only properties which are editable are shown. An inherited class property is editable only when the class it is asserted in is selected, and the assertion is in the current file. For example, with **Man** selected in the taxonomy window and **Inferred** unchecked, as in the case shown in :numref:`figure-KB-Editor-Man-inferred-off.png`, the **KB Editor** editing window shows an empty **Class Property** table for **Man**. This is because all of **Man**’s class properties are inherited from class **Person**. Class **Person** must be selected in order for these properties to be editable. .. _figure-KB-Editor-Man-inferred-off.png: .. figure:: ../../figs/KB-Editor-Man-inferred-off.png :alt: Empty **Class Properties** table for identifer **Man** with **Inferred** unchecked Empty **Class Properties** table for identifer **Man** with **Inferred** unchecked For another example, with family.flr loaded, expand class **Person** and subclass **Man** to show all the individual instances of **Man**. Click to select individual **Peter**. An uneditable birthDate property is shown in **Peter**’s **Individual Properties** table, as shown in :numref:`figure-KB-Editor-Peter-inferred-on.png`. This is because **Peter**’s birthDate property is not asserted in the current file family.flr. .. _figure-KB-Editor-Peter-inferred-on.png: .. figure:: ../../figs/KB-Editor-Peter-inferred-on.png :alt: Uneditable birthDate shown for **Peter** when **Inferred** is checked Uneditable birthDate shown for **Peter** when **Inferred** is checked Uncheck the **Inferred** option and the birthDate property disappears from the editing window, as seen in :numref:`figure-KB-Editor-Peter-inferred-off.png`. Since **Peter**'s birthDate is not asserted in the current file family.flr, it is not editable and therefore not shown when **Inferred** is disabled. .. _figure-KB-Editor-Peter-inferred-off.png: .. figure:: ../../figs/KB-Editor-Peter-inferred-off.png :alt: Property birthDate is removed from **Individual Properties** table for **Peter** with **Inferred** unchecked Property birthDate is removed from **Individual Properties** table for **Peter** with **Inferred** unchecked To edit **Peter**’s birthDate, either follow the hyperlink **Peter.flr** in the editing window, or double click Peter.flr in the navigation tree to make it the current file. Expand **Man** and select **Peter** in the taxonomy window. Then **Peter**’s birthDate property will be shown as an editable property in the editing window, as shown in :numref:`figure-KB-Editor-Peter-birthDate-editable.png`. .. _figure-KB-Editor-Peter-birthDate-editable.png: .. figure:: ../../figs/KB-Editor-Peter-birthDate-editable.png :alt: **Peter**’s birthDate becomes editable when Peter.flr is the current file **Peter**’s birthDate becomes editable when Peter.flr is the current file **Browsing with and without Missing Properties** By default, the **Missing** option is enabled in the **KB Editor** to show properties which are considered missing. Missing properties include properties not yet assigned values, and properties which have assigned values but not yet reached their maximum cardinalities. We will give examples of both types below. When the Missing option is enabled, as shown in :numref:`figure-KB-Editor-missing-property.png`, the **Individual Properties** table for **Eric** includes a few properties with **?** in the **Value** column. These are the missing properties for **Eric**. Address, height and hobby are considered missing because **Eric** has not yet been assigned an address or a height or a hobby. Now consider the property child with a **?** in its **Value** column. It is a missing property for the reason that the child property has a cardinality of any positive number. Although **Eric** already has one child **Isobel**, his child property has not reached its maximum cardinality. Therefore we see an extra child entry in the table to allow more children to be added to **Eric**. The property spouse, on the other hand, has cardinality one. We don't see an extra spouse entry in the table because this property has already reached its maximum cardinality with the one assigned value, namely **Emma**. .. _figure-KB-Editor-missing-property.png: .. figure:: ../../figs/KB-Editor-missing-property.png :alt: Missing properties address, child, height and hobby shown in **Eric**'s **Individual Properties** table Missing properties address, child, height and hobby shown in **Eric**'s **Individual Properties** table Uncheck the Missing option to disable missing properties from being shown in the **KB Editor**. All missing properties mentioned above for **Eric** are now removed from the **Individual Properties** table, as shown in :numref:`figure-KB-Editor-no-missing-property.png`. .. _figure-KB-Editor-no-missing-property.png: .. figure:: ../../figs/KB-Editor-no-missing-property.png :alt: Missing properties address, child, height and hobby removed from **Eric**'s **Individual Properties** table Missing properties address, child, height and hobby removed from **Eric**'s **Individual Properties** table **Performing Search in the Taxonomy Window** **Search for selected identifier** makes use of the **KB Search** plugin to search for all occurrences of the selected identifier. Expand class **Person** and subclass **Man**. Click identifier **Chris**, and then click the **Search selected identifier** icon as shown in :numref:`figure-KB-Editor-search-for-selected-identifier.png`. Search results are returned automatically via the **KB Search** window, as shown in :numref:`figure-KB-Editor-search-results.png`. .. _figure-KB-Editor-search-for-selected-identifier.png: .. figure:: ../../figs/KB-Editor-search-for-selected-identifier.png :alt: **Search for selected identifier** icon in **KB Editor** **Search for selected identifier** icon in **KB Editor** .. _figure-KB-Editor-search-results.png: .. figure:: ../../figs/KB-Editor-search-results.png :alt: **KB Search** window showing search results for **Chris** **KB Search** window showing search results for **Chris** **Browsing Queries and Rules** In the **KB Editor** taxonomy window, click the expand button to the left of **Latent Queries**, as shown in :numref:`figure-KB-Editor-expand-latent-queries.png`, to reveal the list of latent queries defined in family.flr. .. _figure-KB-Editor-expand-latent-queries.png: .. figure:: ../../figs/KB-Editor-expand-latent-queries.png :alt: Expand symbol to the left of **Latent Queries** in **KB Editor** taxonomy window In the expanded list of latent queries, click one of the queries, e.g. ’What is Otavios birthdate?’. The editing window will display the file in which the query is defined. The same query will also be automatically highlighted in the **Text Editor**, as illustrated in :numref:`figure-KB-Editor-Queries.png`. .. _figure-KB-Editor-Queries.png: .. figure:: ../../figs/KB-Editor-Queries.png :alt: List of latent queries in family.flr as shown in **KB Editor** List of latent queries in family.flr as shown in **KB Editor** Click the > or expand button next to **Rules** to reveal the list of rules defined in family.flr. Click one of the rules, e.g. olderThan(?Age1,?Age2). The editing window will display the rule definition and the file in which the rule is defined. The same rule will also be automatically highlighted in the **Text Editor**, as illustrated in :numref:`figure-KB-Editor-Rules.png`. .. _figure-KB-Editor-Rules.png: .. figure:: ../../figs/KB-Editor-Rules.png :alt: List of rules in family.flr as shown in **KB Editor** List of rules in family.flr as shown in **KB Editor**