SlideShare a Scribd company logo
1 of 100
JessTab Tutorial Henrik Eriksson
Outline ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Tip: Slides available at  http://www.ida.liu.se/~her/JessTab/tutorial06/
2. Background ,[object Object],[object Object]
Background (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Why Jess and JessTab? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Practical uses of JessTab ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Examples of applications ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is Jess? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Historical background CLIPS Jess Current Protégé Art OPS5 Protégé-II Cool Protégé-I Java Java KIF/OKBC/Clos Protégé/Win Descendants Influences JessTab
Tool integration – Two possibilities ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],JessTab supports tight integration
Approach – JessTab plug-in for Protégé ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
3. Installation ,[object Object],[object Object],[object Object],[object Object]
Enabling JessTab ,[object Object]
JessTab with no Jess engine
Jess installation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Tip: Development versions of Jess are usually stable
Jess installation (cont.) ,[object Object],[object Object],JessTab.jar jess.jar plugin.properties Tip: The file names sometimes contain version number. Protégé will usually find them anyway
Installation troubleshooting tips ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
4. Interaction with JessTab ,[object Object],[object Object],[object Object],[object Object],[object Object]
Jess console window in Protégé
Console window (upper part) JessTab selected Jess prompt Jess startup message subtabs Jess version Console selected Default engine
Console window (lower part) Enter Jess expressions here Break execution Clear console window Command history Tip: It is possible to copy & paste commands with ctrl-C and ctrl-V Evaluate expression
Console Window (subtabs) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Lists of Jess constructs Various settings The Jess console
5. Introduction to Jess programming ,[object Object],[object Object],[object Object],[object Object],[object Object]
CLIPS ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Jess ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Running Jess ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Exits Protégé if running in JessTab
Jess Facts ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Deftemplate Construct ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sample Deftemplate ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multifield slots ,[object Object],[object Object],[object Object]
Sample Fact Revisited ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ordered Facts ,[object Object],[object Object],[object Object],[object Object],[object Object]
Adding and Removing Facts ,[object Object],[object Object],[object Object],[object Object]
Adding Facts: Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Displaying Facts ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Adding another Fact ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Normally, Jess does not accept duplicate fact entries
Jess Rules ,[object Object],[object Object],[object Object],IF the emergency is a fire THEN the response is to activate the sprinkler system Sample rule:
Jess Rules (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],actions patterns rule header
The Run Command ,[object Object],Jess>   (run)   Jess>   (facts)   f-0 (emergency (type fire)) f-1 (response (action activate-sprinkler-system)) For a total of 2 facts in module MAIN. Jess>
Printing the Result ,[object Object],[object Object],[object Object],[object Object],output stream (t = stdout)
Multiple Rules ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Single-Field Patterns ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Single-Field Wildcards ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Conditional Patterns ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Conditional Patterns (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Conditional Patterns (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Conditional Patterns (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Loading Jess Constructs from a File ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
6. Managing Protégé ontologies with Jess ,[object Object],[object Object],[object Object]
Defining classes and instantiating them Jess>  (defclass Person (is-a :THING) (slot name (type string)) (slot age (type integer)))   TRUE Jess>  (make-instance john of Person (name &quot;John&quot;) (age 20))   <External-Address:SimpleInstance> Jess>
Modifying slots Jess>  (slot-set john age 21)   Jess>  Jess>  (slot-get john age)   21 Jess>
Creating a second instance Jess>  (make-instance sue of Person (name &quot;Sue&quot;) (age 22))   <External-Address:SimpleInstance> Jess> Jess>  (slot-get sue age)   22 Jess>
Functions for knowledge-base operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],instancep instance-existp instance-name instance-address instance-addressp instance-namep slot-existp slot-default-value set-kb-save get-kb-save load-kb-definitions load-project include-project save-project jesstab-version-number jesstab-version-string get-knowledge-base get-tabs
7. Mapping Protégé ontologies to Jess ,[object Object],Protégé ontology Jess facts f-0 f-1 f-2 f-3
Mapping classes Jess>  (defclass Person (is-a :THING) (slot name (type string)) (slot age (type integer)))   TRUE Jess>  (make-instance john of Person (name &quot;John&quot;) (age 20))   <External-Address:SimpleInstance> Jess>  (mapclass Person)   Person Jess>  (facts)   f-0 (object (is-a Person) (is-a-name &quot;Person&quot;) (OBJECT <External-Address:SimpleInstance>) (age 20) (name &quot;John&quot;)) For a total of 1 facts.
The “object” fact ,[object Object],(object (is-a Person) (is-a-name &quot;Person&quot;) (OBJECT <External-Address:SimpleInstance>) (age 20) (name &quot;John&quot;)) Fact name Class name Class name as string Slot values Reference to Protégé instance
Modifying slots Jess>  (slot-set john age 21)   Jess>  (facts)   f-1 (object (is-a Person) (is-a-name &quot;Person&quot;) (OBJECT <External-Address:SimpleInstance>) (age 21) (name &quot;John&quot;)) For a total of 1 facts.
Creating Instances Jess>  (make-instance sue of Person (name &quot;Sue&quot;) (age 22))   <External-Address:SimpleInstance> Jess>  (facts)   f-1 (object (is-a Person) (is-a-name &quot;Person&quot;) (OBJECT <External-Address:SimpleInstance>) (age 21) (name &quot;John&quot;)) f-4 (object (is-a Person) (is-a-name &quot;Person&quot;) (OBJECT <External-Address:SimpleInstance>) (age 22) (name &quot;Sue&quot;)) For a total of 2 facts.
Adding a Jess rule Jess>  (defrule twenty_one (object (is-a Person) (name ?n) (age ?a&:(>= ?a 21))) => (printout t &quot;The person &quot; ?n &quot; is 21 or older&quot; crlf))   TRUE Jess>  (run)   The person John is 21 or older The person Sue is 21 or older 2 Jess>
More rule examples (defrule twenty_two (object (name ?n) (age 22)) => (printout t &quot;The object &quot; ?n &quot; is 22&quot; crlf)) (defrule print_age (object (is-a Person) (name ?n) (age ?a)) => (printout t &quot;The person &quot; ?n &quot; is &quot; ?a crlf))
Accessing instances from rules (defrule print_age_2 (object (is-a Person) (OBJECT ?obj) (name ?n)) => (printout t &quot;The person &quot; ?n &quot; is &quot; (slot-get ?obj age) crlf)) (defrule print_age_3 ?f <- (object (is-a Person) (name ?n)) => (printout t &quot;The person &quot; ?n &quot; is &quot; (slot-get ?f age) crlf))
Modifying slot values from rules (defrule upgrade_my_age ?f <- (object (is-a Person) (name ”Joe Hacker”) (age 20)) => (slot-set ?f age 21)) (defrule upgrade_my_age_2 ?f <- (object (is-a Person) (name ”Joe Hacker”) (age ?a)) => (slot-set ?f age (+ ?a 1))) Tip: Avoid. Infinite loop!
Consistency rules (defrule set_john_doe_if_no_name ?f <- (object (is-a Person) (name nil) (age ?a&:(numberp ?a))) => (slot-set ?f name ”John Doe”) ) (defrule remove_if_no_name_and_no_age ?f <- (object (is-a Person) (name nil) (age nil)) => (unmake-instance ?f) )
Matching instances in rules ,[object Object],(defrule remove_if_duplicate_name_and_age (object (is-a Person) (OBJECT ?p) (name ?n) (age ?a)) (object (is-a Person) (OBJECT ~?p) (name ?n) (age ?a)) => (unmake-instance ?p) )
Matching instances in rules (cont.) ,[object Object],(defrule print_owner_and_pet (object (is-a Person) (OBJECT ?p) (name ?n)) (object (is-a Dog|Cat|Bird) (is-a-name ?type) (owner ?p) (name ?an)) => (printout t &quot;The person &quot; ?n &quot; has a &quot; ?type &quot; called &quot; ?an crlf))
Mappings and rules – Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Question #1: Why mappings? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Question #2: Why does mapclass map to these “object” facts? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Mirroring Jess definitions in Protégé knowledge bases ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Mirroring Jess definitions in Protégé knowledge bases (cont.) Your Jess definitions as first-class citizen in Protégé
Editing Jess definitions in Protégé Jess rule editor in Protégé
Editing Jess definitions in Protégé (cont.) Rule-editor subtab in JessTab
8. Metalevel mappings ,[object Object],[object Object],[object Object],Metaclass Class Instance instance of instance of
Support for Protégé metalevel objects ,[object Object],[object Object],[object Object],[object Object],(make-instance Person of :STANDARD-CLASS (:DIRECT-SUPERCLASSES :THING))
Class definition by instantiation (make-instance of :STANDARD-CLASS (:NAME LivingThing) (:ROLE Abstract) (:DIRECT-SUPERCLASSES :THING)) (make-instance of :STANDARD-CLASS (:NAME Person) (:DIRECT-SUPERCLASSES LivingThing) (:DIRECT-TEMPLATE-SLOTS (make-instance of :STANDARD-SLOT (:NAME name) (:SLOT-VALUE-TYPE String)) (make-instance of :STANDARD-SLOT  (:NAME age) (:SLOT-VALUE-TYPE Integer)) )) (defclass Person (defclass LivingThing
Class definition by instantiation (cont.) ,[object Object],Tip: Classes can also be created programmatically with calls to defclass (which is a construct implemented as a function)
Class definition with custom metaclass (make-instance of :STANDARD-CLASS (:NAME MyMetaClass) (:DIRECT-SUPERCLASSES :STANDARD-CLASS) (:DIRECT-TEMPLATE-SLOTS (make-instance of :STANDARD-SLOT (:NAME AUTHOR) (:SLOT-VALUE-TYPE String)) )) (make-instance of MyMetaClass (:NAME Person2) (:DIRECT-SUPERCLASSES Person) (:DIRECT-TEMPLATE-SLOTS (make-instance of :STANDARD-SLOT (:NAME income) (:SLOT-VALUE-TYPE Integer)) )) ; Set the AUTHOR value for Person2 (slot-set Person2 AUTHOR &quot;The meta man&quot;) Add AUTHOR property to classes
Resulting class with AUTHOR property (instance of MyMetaClass)
Class changes ,[object Object],[object Object],(slot-set Person :DIRECT-TYPE MyMetaClass) (slot-set john :DIRECT-TYPE Person2)
Rules and metalevel objects ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Printing abstract classes in Protégé (mapclass :THING)   (defrule print-all-abstract-classes ?c <- (object ) (test (class-abstractp ?c)) => (printout t &quot;The class &quot; (instance-name ?c) &quot; is abstract.&quot; crlf)) Map every class to Jess Match every object Test for abstract classes Print matches
Modifying ontologies (defrule make-classes-abstract ?c <- (object (:NAME ?n) (:ROLE Concrete) (:DIRECT-INSTANCES )) (not (object (:NAME ?n) (:DIRECT-SUBCLASSES))) => (slot-set ?c :ROLE Abstract))   Change the role to  abstract  for classes that have subclasses, but do not have any instances: Not no subclasses = subclasses exist Concrete classes & no instances Change role
Methods and Message Handlers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Defining methods ,[object Object],[object Object],(defmethod <name> [<index>] [<comment>]  (<parameter-restriction>* [<wildcard-parameter-restriction>]) <action>* ) (defmethod add ((?a STRING) (?b STRING)) (str-cat ?a ?b)) (defmethod add ((?a MyClass) (?b MyClass)) … )
Defining message handlers ,[object Object],[object Object],(defmessage-handler MyClass get-foo () ?self:foo) (defmessage-handler rectangle find-area () (* ?self:side-a ?self:side-b)) (defmessage-handler <class-name> <message-name> [<handler-type>] [<comment>] (<parameter>* [<wildcard-parameter>]) <action>* )
Invoking message handlers ,[object Object],[object Object],[object Object],Jess>  (defclass MyClass (is-a :THING) (slot foo (type integer)))   TRUE Jess>  (make-instance x of MyClass (foo 42))   <External-Address:DefaultSimpleInstance> Jess>  (slot-get x foo)    42 Jess>  (defmessage-handler MyClass get-foo () ?self:foo)   TRUE Jess>  (send x get-foo)   42 Jess>
Methods and Message Handlers – Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
9. JessTab and Protégé OWL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
10. Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Steps ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Rule overview ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Graphical rule overview Personals_Ad Standard_Ad Article page-area width height Content_Layout Rectangle page_area_r1 page_area_r2 size_r1 size_r2 size_r3 size_r4 layout_r1 Instance Fact Rules
Rules – Code (mapclass Content) (defrule area_r1 (object (is-a Personals_Ad|Standard_Ad) (OBJECT ?a) (name ?n) (page_number ?p)) => (assert (page-area ?p Ad ?n &quot;&quot; ?a)) ) (defrule area_r2 (object (is-a Article) (OBJECT ?a) (headline ?h) (text ?t) (page_number ?p)) => (assert (page-area ?p Article ?h ?t ?a)) ) (defrule size_r1 (page-area ?p&:(< ?p 10) Article ? ? ?a) => (assert (width ?a 100.0)) ) (defrule size_r2 (page-area ?p&:(>= ?p 10) Article ? ? ?a) => (assert (width ?a 50.0)) ) (defrule size_r3 (page-area ? Article ? ?t ?a) => (assert (height ?a (* (str-length ?t) 2.0))) ) (defrule size_r4 (page-area ?p Ad ? ? ?a) => (assert (width ?a 50.0) (height ?a 50.0)) ) (defrule layout_r1 (width ?a ?w) (height ?a ?h) => (slot-set ?a layout (make-instance of Content_Layout (main_rectangle (make-instance of Rectangle (width ?w) (height ?h))))) )
Result
11. Conclusion ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tool Web/Library Protégé Jess JADE Your system Your tab JessTab FuzzyJess PrologTab JadeJessProtege FloraTab More Protégé plug-ins More Jess extensions Algernon
Ideas for future work ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Trying JessTab ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Learning more about Jess and JessTab ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary ,[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

Introduction to Gremlin
Introduction to GremlinIntroduction to Gremlin
Introduction to Gremlin
Max De Marzi
 

What's hot (20)

The Rule of Three
The Rule of ThreeThe Rule of Three
The Rule of Three
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume LaforgeGR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
 
JavaOne 2013 - Clojure for Java Developers
JavaOne 2013 - Clojure for Java DevelopersJavaOne 2013 - Clojure for Java Developers
JavaOne 2013 - Clojure for Java Developers
 
Java8 - Interfaces, evolved
Java8 - Interfaces, evolvedJava8 - Interfaces, evolved
Java8 - Interfaces, evolved
 
Grooscript gr8conf
Grooscript gr8confGrooscript gr8conf
Grooscript gr8conf
 
Seven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many ProgrammersSeven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many Programmers
 
Regex-Fu - Juliette Reinders Folmer - Codemotion Rome 2017
Regex-Fu -  Juliette Reinders Folmer - Codemotion Rome 2017Regex-Fu -  Juliette Reinders Folmer - Codemotion Rome 2017
Regex-Fu - Juliette Reinders Folmer - Codemotion Rome 2017
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
модели акторов в с++ миф или реальность
модели акторов в с++ миф или реальностьмодели акторов в с++ миф или реальность
модели акторов в с++ миф или реальность
 
JNI - Java & C in the same project
JNI - Java & C in the same projectJNI - Java & C in the same project
JNI - Java & C in the same project
 
Virtual Separation of Concerns (2011 Update)
Virtual Separation of Concerns (2011 Update)Virtual Separation of Concerns (2011 Update)
Virtual Separation of Concerns (2011 Update)
 
Introduction to Gremlin
Introduction to GremlinIntroduction to Gremlin
Introduction to Gremlin
 
Designing with Groovy Traits - Gr8Conf India
Designing with Groovy Traits - Gr8Conf IndiaDesigning with Groovy Traits - Gr8Conf India
Designing with Groovy Traits - Gr8Conf India
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
Objective-C: Under The Hood
Objective-C: Under The HoodObjective-C: Under The Hood
Objective-C: Under The Hood
 
Good Code
Good CodeGood Code
Good Code
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 

Similar to Jess Tab Tutorial

Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - Stockholm
Jan Kronquist
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
HamletDRC
 

Similar to Jess Tab Tutorial (20)

Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - Stockholm
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
tictactoe groovy
tictactoe groovytictactoe groovy
tictactoe groovy
 
Oleksii Holub "Expression trees in C#"
Oleksii Holub "Expression trees in C#" Oleksii Holub "Expression trees in C#"
Oleksii Holub "Expression trees in C#"
 
Groovy And Grails JUG Trento
Groovy And Grails JUG TrentoGroovy And Grails JUG Trento
Groovy And Grails JUG Trento
 
Expression trees in C#
Expression trees in C#Expression trees in C#
Expression trees in C#
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
 
What's new with JavaScript in GNOME: The 2020 edition (GUADEC 2020)
What's new with JavaScript in GNOME: The 2020 edition (GUADEC 2020)What's new with JavaScript in GNOME: The 2020 edition (GUADEC 2020)
What's new with JavaScript in GNOME: The 2020 edition (GUADEC 2020)
 
Concepts of JetBrains MPS
Concepts of JetBrains MPSConcepts of JetBrains MPS
Concepts of JetBrains MPS
 
concurrency with GPars
concurrency with GParsconcurrency with GPars
concurrency with GPars
 
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
(De)serial Killers - BSides Las Vegas & AppSec IL 2018(De)serial Killers - BSides Las Vegas & AppSec IL 2018
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
 
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
(De)serial Killers - BSides Las Vegas & AppSec IL 2018(De)serial Killers - BSides Las Vegas & AppSec IL 2018
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
 
Os Secoske
Os SecoskeOs Secoske
Os Secoske
 
Building modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and java
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To Scala
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with Clojure
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talk
 

Recently uploaded

Recently uploaded (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

Jess Tab Tutorial

  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. Historical background CLIPS Jess Current Protégé Art OPS5 Protégé-II Cool Protégé-I Java Java KIF/OKBC/Clos Protégé/Win Descendants Influences JessTab
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. JessTab with no Jess engine
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. Jess console window in Protégé
  • 20. Console window (upper part) JessTab selected Jess prompt Jess startup message subtabs Jess version Console selected Default engine
  • 21. Console window (lower part) Enter Jess expressions here Break execution Clear console window Command history Tip: It is possible to copy & paste commands with ctrl-C and ctrl-V Evaluate expression
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50. Defining classes and instantiating them Jess> (defclass Person (is-a :THING) (slot name (type string)) (slot age (type integer)))  TRUE Jess> (make-instance john of Person (name &quot;John&quot;) (age 20))  <External-Address:SimpleInstance> Jess>
  • 51. Modifying slots Jess> (slot-set john age 21)  Jess> Jess> (slot-get john age)  21 Jess>
  • 52. Creating a second instance Jess> (make-instance sue of Person (name &quot;Sue&quot;) (age 22))  <External-Address:SimpleInstance> Jess> Jess> (slot-get sue age)  22 Jess>
  • 53.
  • 54.
  • 55. Mapping classes Jess> (defclass Person (is-a :THING) (slot name (type string)) (slot age (type integer)))  TRUE Jess> (make-instance john of Person (name &quot;John&quot;) (age 20))  <External-Address:SimpleInstance> Jess> (mapclass Person)  Person Jess> (facts)  f-0 (object (is-a Person) (is-a-name &quot;Person&quot;) (OBJECT <External-Address:SimpleInstance>) (age 20) (name &quot;John&quot;)) For a total of 1 facts.
  • 56.
  • 57. Modifying slots Jess> (slot-set john age 21)  Jess> (facts)  f-1 (object (is-a Person) (is-a-name &quot;Person&quot;) (OBJECT <External-Address:SimpleInstance>) (age 21) (name &quot;John&quot;)) For a total of 1 facts.
  • 58. Creating Instances Jess> (make-instance sue of Person (name &quot;Sue&quot;) (age 22))  <External-Address:SimpleInstance> Jess> (facts)  f-1 (object (is-a Person) (is-a-name &quot;Person&quot;) (OBJECT <External-Address:SimpleInstance>) (age 21) (name &quot;John&quot;)) f-4 (object (is-a Person) (is-a-name &quot;Person&quot;) (OBJECT <External-Address:SimpleInstance>) (age 22) (name &quot;Sue&quot;)) For a total of 2 facts.
  • 59. Adding a Jess rule Jess> (defrule twenty_one (object (is-a Person) (name ?n) (age ?a&:(>= ?a 21))) => (printout t &quot;The person &quot; ?n &quot; is 21 or older&quot; crlf))  TRUE Jess> (run)  The person John is 21 or older The person Sue is 21 or older 2 Jess>
  • 60. More rule examples (defrule twenty_two (object (name ?n) (age 22)) => (printout t &quot;The object &quot; ?n &quot; is 22&quot; crlf)) (defrule print_age (object (is-a Person) (name ?n) (age ?a)) => (printout t &quot;The person &quot; ?n &quot; is &quot; ?a crlf))
  • 61. Accessing instances from rules (defrule print_age_2 (object (is-a Person) (OBJECT ?obj) (name ?n)) => (printout t &quot;The person &quot; ?n &quot; is &quot; (slot-get ?obj age) crlf)) (defrule print_age_3 ?f <- (object (is-a Person) (name ?n)) => (printout t &quot;The person &quot; ?n &quot; is &quot; (slot-get ?f age) crlf))
  • 62. Modifying slot values from rules (defrule upgrade_my_age ?f <- (object (is-a Person) (name ”Joe Hacker”) (age 20)) => (slot-set ?f age 21)) (defrule upgrade_my_age_2 ?f <- (object (is-a Person) (name ”Joe Hacker”) (age ?a)) => (slot-set ?f age (+ ?a 1))) Tip: Avoid. Infinite loop!
  • 63. Consistency rules (defrule set_john_doe_if_no_name ?f <- (object (is-a Person) (name nil) (age ?a&:(numberp ?a))) => (slot-set ?f name ”John Doe”) ) (defrule remove_if_no_name_and_no_age ?f <- (object (is-a Person) (name nil) (age nil)) => (unmake-instance ?f) )
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70. Mirroring Jess definitions in Protégé knowledge bases (cont.) Your Jess definitions as first-class citizen in Protégé
  • 71. Editing Jess definitions in Protégé Jess rule editor in Protégé
  • 72. Editing Jess definitions in Protégé (cont.) Rule-editor subtab in JessTab
  • 73.
  • 74.
  • 75. Class definition by instantiation (make-instance of :STANDARD-CLASS (:NAME LivingThing) (:ROLE Abstract) (:DIRECT-SUPERCLASSES :THING)) (make-instance of :STANDARD-CLASS (:NAME Person) (:DIRECT-SUPERCLASSES LivingThing) (:DIRECT-TEMPLATE-SLOTS (make-instance of :STANDARD-SLOT (:NAME name) (:SLOT-VALUE-TYPE String)) (make-instance of :STANDARD-SLOT (:NAME age) (:SLOT-VALUE-TYPE Integer)) )) (defclass Person (defclass LivingThing
  • 76.
  • 77. Class definition with custom metaclass (make-instance of :STANDARD-CLASS (:NAME MyMetaClass) (:DIRECT-SUPERCLASSES :STANDARD-CLASS) (:DIRECT-TEMPLATE-SLOTS (make-instance of :STANDARD-SLOT (:NAME AUTHOR) (:SLOT-VALUE-TYPE String)) )) (make-instance of MyMetaClass (:NAME Person2) (:DIRECT-SUPERCLASSES Person) (:DIRECT-TEMPLATE-SLOTS (make-instance of :STANDARD-SLOT (:NAME income) (:SLOT-VALUE-TYPE Integer)) )) ; Set the AUTHOR value for Person2 (slot-set Person2 AUTHOR &quot;The meta man&quot;) Add AUTHOR property to classes
  • 78. Resulting class with AUTHOR property (instance of MyMetaClass)
  • 79.
  • 80.
  • 81. Printing abstract classes in Protégé (mapclass :THING)   (defrule print-all-abstract-classes ?c <- (object ) (test (class-abstractp ?c)) => (printout t &quot;The class &quot; (instance-name ?c) &quot; is abstract.&quot; crlf)) Map every class to Jess Match every object Test for abstract classes Print matches
  • 82. Modifying ontologies (defrule make-classes-abstract ?c <- (object (:NAME ?n) (:ROLE Concrete) (:DIRECT-INSTANCES )) (not (object (:NAME ?n) (:DIRECT-SUBCLASSES))) => (slot-set ?c :ROLE Abstract))   Change the role to abstract for classes that have subclasses, but do not have any instances: Not no subclasses = subclasses exist Concrete classes & no instances Change role
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92. Graphical rule overview Personals_Ad Standard_Ad Article page-area width height Content_Layout Rectangle page_area_r1 page_area_r2 size_r1 size_r2 size_r3 size_r4 layout_r1 Instance Fact Rules
  • 93. Rules – Code (mapclass Content) (defrule area_r1 (object (is-a Personals_Ad|Standard_Ad) (OBJECT ?a) (name ?n) (page_number ?p)) => (assert (page-area ?p Ad ?n &quot;&quot; ?a)) ) (defrule area_r2 (object (is-a Article) (OBJECT ?a) (headline ?h) (text ?t) (page_number ?p)) => (assert (page-area ?p Article ?h ?t ?a)) ) (defrule size_r1 (page-area ?p&:(< ?p 10) Article ? ? ?a) => (assert (width ?a 100.0)) ) (defrule size_r2 (page-area ?p&:(>= ?p 10) Article ? ? ?a) => (assert (width ?a 50.0)) ) (defrule size_r3 (page-area ? Article ? ?t ?a) => (assert (height ?a (* (str-length ?t) 2.0))) ) (defrule size_r4 (page-area ?p Ad ? ? ?a) => (assert (width ?a 50.0) (height ?a 50.0)) ) (defrule layout_r1 (width ?a ?w) (height ?a ?h) => (slot-set ?a layout (make-instance of Content_Layout (main_rectangle (make-instance of Rectangle (width ?w) (height ?h))))) )
  • 95.
  • 96. Tool Web/Library Protégé Jess JADE Your system Your tab JessTab FuzzyJess PrologTab JadeJessProtege FloraTab More Protégé plug-ins More Jess extensions Algernon
  • 97.
  • 98.
  • 99.
  • 100.