NL to OCL via SBVR
-
Upload
imran-bajwa -
Category
Education
-
view
920 -
download
0
description
Transcript of NL to OCL via SBVR
School of Computer ScienceUniversity of Birmingham
UK
Translation of Natural Language Specification to OCL
A PhD Research Work PresentationA PhD Research Work Presentation
RSMG 2RSMG 2
Imran Sarwar BajwaPhD Student
Natural Language Processing [email protected]
29 | April | 2010 2 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
Presentation Foot Steps
1. Introduction
1.1 Motivation
1.2 Basic Concepts
1.3 Research Problem
1.4 Research Objectives
2. Concluded Work
2.1 State of the Art
2.2 Proposed Solution
3. Conclusions
29 | April | 2010 3 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
1.1 Motivation
1.1 Motivation Object Constraint Language (OCL) is used to annotate Unified Modeling Language (UML)
models with constraints.
But OCL is the least used language among the 13 UML languages.
OCL is difficult to write due to its hard syntax.
Creating OCL code is difficult and that results in less
adaptability of OCL
Constraints specification is easy to write in natural language e.g. English
A Natural language interface can be useful in automatic creation of OCL
29 | April | 2010 4 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
1.2 Background
Natural Language (NL)Natural Language (NL)
Natural languages (NL) e.g. English, Arabic, French, etc are basic source of communication for humans.
Computational processing of NL is a long standing challenge.
Basic steps involved in translation of Natural Language Text are following
NL Text(Source String)
Lexical Analysis
(Tokenizing)
g
Syntactic Analysis(Parsing)
Semantic Analysis(Meaning
Extraction)
Output(Target String)
Translation
Basic steps of Natural language Translation
29 | April | 2010 5 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
1.2 Background
Object Constraint LanguageObject Constraint Language
An OCL constraint defines a restriction on state or behaviour of an entity in a UML model.
a. Invariants: The invariants are conditions those have to be TRUE always.
context driver
inv: self.age >= 18
b. Precondition: This constraint that should be TRUE always before the execution of a method starts.
context driver :: isAdult(dDOB: Integer): Booleanpre: dDOB >= 1990
b. Postcondition: This constraint should be TRUE always after the execution of a method has finished.
context driver :: isAdult(dDOB: Integer): Boolean
post: result >= 18
29 | April | 2010 6 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
1.2 Background
context Flight
inv self.maxNrPassengers <= 500
Airport
Flight
*
*
departTime: TimearrivalTime: Timeduration : IntervalmaxNrPassengers: Integer
origin
desti-nation
name: String
arrivingFlights
departingFlights
1
1
Flight Capacity Constraint:Flight Capacity Constraint: The maximum number of passengers that can be on a
flight must be less than or equal to 500.
OCL Simple ExampleOCL Simple Example
29 | April | 2010 7 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
1.2 Background
context Department
inv MaxSalary: Department.allInstances() -> forAll(d|not d.employee -> select(e|e.age<25) -> exists(e|e.salary > d.maxJuniorSal)).
Junior Employee Salary Constraint:Junior Employee Salary Constraint: The maximum salary of a junior employee
those with an age lower than 25 can not earn more than the maximum junior salary value
defined for their department.
OCL Hard ExampleOCL Hard Example
29 | April | 2010 8 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
1.2 Background
Junior Employee Salary Constraint:Junior Employee Salary Constraint: In the enroll() operation of LoyaltyProgram, the
Postcondition includes that there is no one more customer than before and that the new
customer’s loyalty account has no points and no transactions.
OCL Very Hard ExampleOCL Very Hard Example
context LoyaltyProgram::enroll(int c:Customer)
inv pre: not customer -> includes(c)
post: customer = customer @ pre -> including(c)
post: membership -> select(customer=c) -> forAll(
loyaltyAccount -> notEmpty() and
loyaltyAccount.points = 0 and
loyaltyAccount.transations -> isEmpty)
29 | April | 2010 9 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
1.2 Background
Context LineFinder::rows : Set(Set(Integer))
derive: Set{ Set{0, 3, 6}, Set{1, 4, 7}, Set{2, 5, 8}, Set{0, 1, 2}, Set{3, 4, 5}, Set{6, 7, 8}, Set{0, 4, 8}, Set{6, 4, 2}}
Context LineFinder::findWinningLines(board:Sequence(Piece)) :
Set(Line)
body: let winners : Set(Set(Integer)) = LineFinder::rows -> select(row | row -> forAll(a, b : Integer | board -> at(a) = board -> at(b) and board -> at(a) <> Piece::Empty) ) in winners -> iterate(row : Set(Integer); lines : Set(Line) = Set{} | lines -> including(LineFinder::newLine(board -> at(row -> any(true)), row)))
Another OCL very Hard ExampleAnother OCL very Hard Example
TIC-TAC-TOE Winning Line Constraint:TIC-TAC-TOE Winning Line Constraint: Finds all winning lines where it's possible
to have more than one line, but if the other rules are enforced and all winning lines
should be for the same piece.
29 | April | 2010 10 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
1.2 Background
Semantic Business Vocabulary and Rules (SBVR)Semantic Business Vocabulary and Rules (SBVR)
SBVR has two components
SBVR vocabulary
SBVR vocabulary is made up of two elements: concepts and fact types.
- A concept can be a noun Concept or individual Concept.
- A fact type is a verb that specifies the relationship among different concepts in a business rule.
SBVR rules
SBVR rules are of two types: Definitional Rules and Behavioural Rules.
a. Definitional Rules:
Definitional Rules or structural rules are used to define an organization’s setup e.g . It is necessary that each customer has at least one bank account.
b. Behavioural Rules:
Behavioural Rules or operative rules express the conduct of an entity e.g. It is obligatory that each customer
can withdraw at most GBP 200 per day.
29 | April | 2010 11 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
1.3 Problem Description
1.3. Problem Description
OCL is hard to write due to a number of reasons. Major reasons are OCL syntax is difficult to grasp.
Manually creation of OCL code results in incorrect and erroneous OCL constraints.
So many OCL tools but they provide only type-checking facilities.
OCL is not adaptable in its current interface.
English is difficult to process due to following reasons
English is vast and has no domain boundaries
English sentence structure is ambiguous
Most English words have multiple senses
A single meaning can be represented in multiple ways
29 | April | 2010 12 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
1.4 Research Objectives
1.4. Objectives of Research
Major objectives of the research are
To make OCL more adoptable through translation from natural languages.
Overcoming limitations of natural languages with the help of SBVR
Presenting a framework that can be used to automatically generate OCL code from
natural language specification .
Creating a tool for creating OCL from NL by implementing the proposed framework.
29 | April | 2010 13 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
2.1 Related Work
2.1 State of the Art
NL Specification to Object Oriented Analysis (Moreno, 1997, Kop, 2002; Lee,
2002; Perez-Gonzalez, 2002; Mich, 1996; Li, 2004; Mala, 2006)
NL Specification to UML Diagrams (Bryant, 2003; Harmain, 2003; Clavel, 2007;
Seco, 2004; Oliviera, 2004; Ilieva, 2005; Whittle, 2009; Kovacs, 2009)
No work done for NL to OCL translation
SBVR based Controlled Natural Languages (Kliener, 2009; Silvie, 2009;
Spreeuwenburg, 2009)
SBVR specification to UML model (Raj, 2008)
29 | April | 2010 14 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
2.2 Proposed Solution
Natural Language Specifications
Structured English based SBVR
SBVR to OCL Translation
Mapping NL to SBVR Rules
Validated OCL code
Designer
UML Model
SBVR Rules
OCL Expression
Application Scenario of Natural language to OCL transformation
context driverinv: self.age >= 18
It is necessary that each driver must be at least 18 years old.
A driver should be 18 years old.
29 | April | 2010 15 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
3. Conclusion
Finally!!
OCL can be made more adaptable and
usable by providing a natural language e.g.
English based user interface.
29 | April | 2010 16 | 16Natural Language Processing Group
School of Computer ScienceUniversity of Birmingham, UK
Questions
?