SlideShare a Scribd company logo
SEMANTIC NETWORK BASED API
USAGE PATTERN EXTRACTION &
LEARNING
Mohammad Masudur Rahman
mor543@mail.usask.ca
Department of Computer Science
University of Saskatchewan
PRESENTATION OVERVIEW
Introduction
ļ‚¢ Motivating Example
ļ‚¢ Background Concepts
ļ‚¢ Proposed Approach
ļ‚¢ Semantic Network of Source code
ļ‚¢ API Usage Pattern Extraction
ļ‚¢ Pattern Learning & Visualization
ļ‚¢ Experimental Results & Discussions
ļ‚¢ Threats to Validity
ļ‚¢ Conclusion & Future Works
ļ‚¢
INTRODUCTION
API (Application Programming Interface) Libraries
ļ‚¢ API Documentation, API Browser, forums
ļ‚¢ API Usage learning for developers
ļ‚¢ Existing projects using APIs
ļ‚¢ API Usage Patterns
ļ‚¢
WHAT IS API USAGE PATTERN?
A frequent and consistent sequence of API method
calls and field accesses
ļ‚¢ Performs a particular programming task.
ļ‚¢ Widely used in multiple projects
ļ‚¢ Widely accepted by developers community
ļ‚¢
API USAGE PATTERN
BIG QUESTION?

How to extract the API usage patterns from
the source code?
SEMANTIC WEB OR NETWORK
ļ‚¢

What is the living place of the author of a particular
software manual?
MOTIVATING EXAMPLE
MOTIVATING EXAMPLE
RESEARCH QUESTIONS
RQ 1: Can semantic network technologies
represent the semantics of OO source code
properly?
ļ‚¢ RQ 2: Can this representation be used for API
usage pattern extraction and learning?
ļ‚¢
BACKGROUND CONCEPTS
API Usage Patterns
ļ‚¢ API Usage Violation & Anomalies
ļ‚¢ Semantic Web
ļ‚¢ Semantic Network of Source Code
ļ‚¢ Resource Description Framework (RDF)
ļ‚¢ RDF Statement or Triples
ļ‚¢
RDF TRIPLE (BUILDING BLOCK OF SEMANTIC
WEB OR NETWORK)
Subject

Predicate

Object
PROPOSED APPROACH FOR API
USAGE PATTERN EXTRACTION &
LEARNING
PROPOSED APPROACH FOR API USAGE
PATTERN EXTRACTION & LEARNING
1
API Class
List

API
Classes

3

4
Yes

Contains
API ?

2
OSS
Projects

Parsed
Expressions

Source
files

Source code
parser

5
Semantic
Network
Builder

RDF Files
7

6

No

Patterns

API Usage
Pattern Manager
Pattern

9
Pattern Source
Skeleton Builder

Pattern

8
RDF Pattern
Visualizer

API Pattern
Explorer
SOURCE CODE SEMANTIC NETWORK
Java
Source code

AST Parser
(Javaparser)

API Expression
selection rules

Apache Jena
Framework

Java
Expressions
RDF Maker

RDF
Network
RDF Triples
API USAGE PATTERN EXTRACTION

Common Sub-graph Selection

Candidate API
usage Patterns

All Usages of
an API Class

Yes
Selected
API Usage
Patterns

Pattern
Score >
threshold ?

No
Discarded
EXPERIMENTAL RESULTS
25 Open source Projects
ļ‚¢ 3 API libraries (java.io, java.util, java.awt)
ļ‚¢ 250 API classes selected
ļ‚¢ API usages found for 113 API classes
ļ‚¢ Pattern found for 76 API classes
ļ‚¢ Total 776 patterns
ļ‚¢
API USAGE PATTERNS
SOURCE CODE SKELETON

Fig: BufferedInputStream Usage Pattern
EXPERIMENTAL RESULTS
Project

#Class

#M &C

#ATCF

#ADCF

#ATPF

#ADPF

Ant-Contrib 186

1388

96

23

1865

280

AOI

461

6489

218

55

1651

494

Groimp

1202

13875

132

41

1632

407

JFreechart

1059

12368

507

38

6841

410

JHotdraw7

689

7330

310

49

2547

462

#M & C =Methods & Constructors, #ATCF=Total API class,
#ADCF=Distinct API class, #ATPF=Total API Patterns found,
#ADPF=Distinct API Patterns found
PATTERNS PER CLASS

Fig: # patterns extracted per class comparison
RESULTS DISCUSSION
RQ 1: Can semantic network technologies
represent the semantics of OO source code
properly?
ļ‚¢ Graph-based API Usage Extraction by Nguyen et
al, FSE, 2009 : Incomplete semantics for edges and
attributes
ļ‚¢ Source code ontology by Wursch et al, ICSE, 2010
: Does not represent the complete source code
ļ‚¢ The proposed approach captures expression level
syntax and semantics
ļ‚¢ Focuses on API usage patterns
ļ‚¢
RESULTS DISCUSSION
RQ 2: Can this representation be used for API
usage pattern extraction and learning?
ļ‚¢ Successfully extracts 776 patterns for 76 API
classes from 25 open source projects
ļ‚¢ A potential approach to be explored more for API
usage pattern exploration
ļ‚¢ Visualization of RDF network helps in learning
ļ‚¢ Source code as visual entities rather than lines
ļ‚¢ More comprehensive idea about OO source code
ļ‚¢ Applicable for complex OO relationships
ļ‚¢ Very useful for quick learning
ļ‚¢
THREATS TO VALIDITY
Representing complete semantics: a non-trivial
task.
ļ‚¢ More expressions for more accurate representation
ļ‚¢ RDF pattern visualization within limited display
ļ‚¢ Need to be introduced with RDF convention
ļ‚¢
CONCLUSION & FUTURE WORKS
Applicability of semantic web technologies for API
usage pattern extraction
ļ‚¢ Semantic representation for learning by the
developers
ļ‚¢ Real world user study
ļ‚¢ Extracted patterns for automatic code completion in
the IDE.
ļ‚¢ Extracted patterns for API violation and anomaly
detection
ļ‚¢
THANK YOU!!!
REFERENCES
[1] Semantic web diagram.URL http://www.w3.org/
Talks/2002/10/16-sw/slide7-0.html.
[2] Tung Thanh Nguyen, Hoan Anh Nguyen, NamH.Pham, JafarM.Al-Kofahi, and
TienN.Nguyen. Graph-based mining of multiple object usage patterns. In Proc.
ESEC/FSE, 2009, pages 383-392.
[3] M.Wursch, G.Ghezzi, G.Reif,and H.C.Gall. Supporting developers with natural
language queries. In Proc. ICSE, 2010,pages 165-174
[4] Tao Xie and Jian Pei. Mapo:mining api usages from
open source repositories. In Proc. MSR, 2006, pages 574-57
[5] Semantic web technology.URL http://www.w3.org/
2001/sw
[6] Visual learning style.URL http://www.learning-styles-online.com/style/visualspatial.
[7] Apache Jena framework.URL http://jena.apache.org/.
[8] Javaparser-java 1.5 parser and ast.URL http://code.google.com/p/javaparser/.
[9] RDF-gravity tool.URL http://semweb.salzburgresearch.at/apps/rdf-gravity/.
Ad

More Related Content

Viewers also liked (20)

USING RELATIONAL MODEL TO STORE OWL ONTOLOGIES AND FACTS
USING RELATIONAL MODEL TO STORE OWL ONTOLOGIES AND FACTSUSING RELATIONAL MODEL TO STORE OWL ONTOLOGIES AND FACTS
USING RELATIONAL MODEL TO STORE OWL ONTOLOGIES AND FACTS
csandit
Ā 
Human resource management Software, Resume Extraction Software, Recruitment D...
Human resource management Software, Resume Extraction Software, Recruitment D...Human resource management Software, Resume Extraction Software, Recruitment D...
Human resource management Software, Resume Extraction Software, Recruitment D...
Vinay Johar
Ā 
Ontology and its various aspects
Ontology and its various aspectsOntology and its various aspects
Ontology and its various aspects
samhati27
Ā 
Artificial neural network architectures
Artificial neural network architecturesArtificial neural network architectures
Artificial neural network architectures
Erin Brunston
Ā 
Ann
Ann Ann
Ann
vini89
Ā 
Neural networks
Neural networksNeural networks
Neural networks
Presentaionslive.blogspot.com
Ā 
Branch And Bound and Beam Search Feature Selection Algorithms
Branch And Bound and Beam Search Feature Selection AlgorithmsBranch And Bound and Beam Search Feature Selection Algorithms
Branch And Bound and Beam Search Feature Selection Algorithms
Chamin Nalinda Loku Gam Hewage
Ā 
Artificial Neural Network
Artificial Neural NetworkArtificial Neural Network
Artificial Neural Network
Burhan Muzafar
Ā 
PRIVACY PRESERVING BACK-PROPOGATION NEURAL NETWORK LEARNING MADE PRACTICAL WI...
PRIVACY PRESERVING BACK-PROPOGATION NEURAL NETWORK LEARNING MADE PRACTICAL WI...PRIVACY PRESERVING BACK-PROPOGATION NEURAL NETWORK LEARNING MADE PRACTICAL WI...
PRIVACY PRESERVING BACK-PROPOGATION NEURAL NETWORK LEARNING MADE PRACTICAL WI...
Thushara Maruthiyat
Ā 
Neural Network Presentation
Neural Network PresentationNeural Network Presentation
Neural Network Presentation
Omoye
Ā 
Artificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console applicationArtificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console application
Eduardo Gulias Davis
Ā 
é”žē„žē¶“ē¶²č·Æć€čŖžę„ē›øä¼¼åŗ¦(äø€å€‹äøå«Œå°‘ć€å…©å€‹ę°ę°å„½)
é”žē„žē¶“ē¶²č·Æć€čŖžę„ē›øä¼¼åŗ¦(äø€å€‹äøå«Œå°‘ć€å…©å€‹ę°ę°å„½)é”žē„žē¶“ē¶²č·Æć€čŖžę„ē›øä¼¼åŗ¦(äø€å€‹äøå«Œå°‘ć€å…©å€‹ę°ę°å„½)
é”žē„žē¶“ē¶²č·Æć€čŖžę„ē›øä¼¼åŗ¦(äø€å€‹äøå«Œå°‘ć€å…©å€‹ę°ę°å„½)
Ming-Chi Liu
Ā 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
Institute of Technology Telkom
Ā 
Introduction to Neural networks (under graduate course) Lecture 9 of 9
Introduction to Neural networks (under graduate course) Lecture 9 of 9Introduction to Neural networks (under graduate course) Lecture 9 of 9
Introduction to Neural networks (under graduate course) Lecture 9 of 9
Randa Elanwar
Ā 
Artificial Neural Networks Lect3: Neural Network Learning rules
Artificial Neural Networks Lect3: Neural Network Learning rulesArtificial Neural Networks Lect3: Neural Network Learning rules
Artificial Neural Networks Lect3: Neural Network Learning rules
Mohammed Bennamoun
Ā 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
ReachLocal Services India
Ā 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
Vajiheh Zoghiyan
Ā 
Lecture artificial neural networks and pattern recognition
Lecture   artificial neural networks and pattern recognitionLecture   artificial neural networks and pattern recognition
Lecture artificial neural networks and pattern recognition
Hưng Đặng
Ā 
Neural
NeuralNeural
Neural
Archit Rastogi
Ā 
Artificial intelligence and Neural Network
Artificial intelligence and Neural NetworkArtificial intelligence and Neural Network
Artificial intelligence and Neural Network
Abdullah Saghir Ahmad
Ā 
USING RELATIONAL MODEL TO STORE OWL ONTOLOGIES AND FACTS
USING RELATIONAL MODEL TO STORE OWL ONTOLOGIES AND FACTSUSING RELATIONAL MODEL TO STORE OWL ONTOLOGIES AND FACTS
USING RELATIONAL MODEL TO STORE OWL ONTOLOGIES AND FACTS
csandit
Ā 
Human resource management Software, Resume Extraction Software, Recruitment D...
Human resource management Software, Resume Extraction Software, Recruitment D...Human resource management Software, Resume Extraction Software, Recruitment D...
Human resource management Software, Resume Extraction Software, Recruitment D...
Vinay Johar
Ā 
Ontology and its various aspects
Ontology and its various aspectsOntology and its various aspects
Ontology and its various aspects
samhati27
Ā 
Artificial neural network architectures
Artificial neural network architecturesArtificial neural network architectures
Artificial neural network architectures
Erin Brunston
Ā 
Ann
Ann Ann
Ann
vini89
Ā 
Branch And Bound and Beam Search Feature Selection Algorithms
Branch And Bound and Beam Search Feature Selection AlgorithmsBranch And Bound and Beam Search Feature Selection Algorithms
Branch And Bound and Beam Search Feature Selection Algorithms
Chamin Nalinda Loku Gam Hewage
Ā 
Artificial Neural Network
Artificial Neural NetworkArtificial Neural Network
Artificial Neural Network
Burhan Muzafar
Ā 
PRIVACY PRESERVING BACK-PROPOGATION NEURAL NETWORK LEARNING MADE PRACTICAL WI...
PRIVACY PRESERVING BACK-PROPOGATION NEURAL NETWORK LEARNING MADE PRACTICAL WI...PRIVACY PRESERVING BACK-PROPOGATION NEURAL NETWORK LEARNING MADE PRACTICAL WI...
PRIVACY PRESERVING BACK-PROPOGATION NEURAL NETWORK LEARNING MADE PRACTICAL WI...
Thushara Maruthiyat
Ā 
Neural Network Presentation
Neural Network PresentationNeural Network Presentation
Neural Network Presentation
Omoye
Ā 
Artificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console applicationArtificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console application
Eduardo Gulias Davis
Ā 
é”žē„žē¶“ē¶²č·Æć€čŖžę„ē›øä¼¼åŗ¦(äø€å€‹äøå«Œå°‘ć€å…©å€‹ę°ę°å„½)
é”žē„žē¶“ē¶²č·Æć€čŖžę„ē›øä¼¼åŗ¦(äø€å€‹äøå«Œå°‘ć€å…©å€‹ę°ę°å„½)é”žē„žē¶“ē¶²č·Æć€čŖžę„ē›øä¼¼åŗ¦(äø€å€‹äøå«Œå°‘ć€å…©å€‹ę°ę°å„½)
é”žē„žē¶“ē¶²č·Æć€čŖžę„ē›øä¼¼åŗ¦(äø€å€‹äøå«Œå°‘ć€å…©å€‹ę°ę°å„½)
Ming-Chi Liu
Ā 
Introduction to Neural networks (under graduate course) Lecture 9 of 9
Introduction to Neural networks (under graduate course) Lecture 9 of 9Introduction to Neural networks (under graduate course) Lecture 9 of 9
Introduction to Neural networks (under graduate course) Lecture 9 of 9
Randa Elanwar
Ā 
Artificial Neural Networks Lect3: Neural Network Learning rules
Artificial Neural Networks Lect3: Neural Network Learning rulesArtificial Neural Networks Lect3: Neural Network Learning rules
Artificial Neural Networks Lect3: Neural Network Learning rules
Mohammed Bennamoun
Ā 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
Vajiheh Zoghiyan
Ā 
Lecture artificial neural networks and pattern recognition
Lecture   artificial neural networks and pattern recognitionLecture   artificial neural networks and pattern recognition
Lecture artificial neural networks and pattern recognition
Hưng Đặng
Ā 
Artificial intelligence and Neural Network
Artificial intelligence and Neural NetworkArtificial intelligence and Neural Network
Artificial intelligence and Neural Network
Abdullah Saghir Ahmad
Ā 

Similar to API Usage Pattern Extraction using Semantic Similarity (20)

PRIME OOPSLA12 paper
PRIME OOPSLA12 paperPRIME OOPSLA12 paper
PRIME OOPSLA12 paper
Eran Yahav
Ā 
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Coen De Roover
Ā 
Automating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight SemanticsAutomating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight Semantics
mmaleshkova
Ā 
API Testing Interview Questions PDF By ScholarHat
API Testing Interview Questions PDF By ScholarHatAPI Testing Interview Questions PDF By ScholarHat
API Testing Interview Questions PDF By ScholarHat
Scholarhat
Ā 
Api design best practice
Api design best practiceApi design best practice
Api design best practice
Red Hat
Ā 
Crossing the chasm between ontology engineering and application development
Crossing the chasm between ontology engineering and application developmentCrossing the chasm between ontology engineering and application development
Crossing the chasm between ontology engineering and application development
Paola Espinoza-Arias
Ā 
Ibm_interconnect_restapi_workshop
Ibm_interconnect_restapi_workshopIbm_interconnect_restapi_workshop
Ibm_interconnect_restapi_workshop
Shubhra Kar
Ā 
API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)
Tom Johnson
Ā 
Api design part 1
Api design part 1Api design part 1
Api design part 1
Ibrahim Elsawaf
Ā 
PPT for Seminar.pptx
PPT for Seminar.pptxPPT for Seminar.pptx
PPT for Seminar.pptx
Akshay Bhujbal
Ā 
Practices and tools for building better APIs
Practices and tools for building better APIsPractices and tools for building better APIs
Practices and tools for building better APIs
NLJUG
Ā 
Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)
Peter Hendriks
Ā 
Cross-Lingual Web API Classification
Cross-Lingual Web API ClassificationCross-Lingual Web API Classification
Cross-Lingual Web API Classification
mmaleshkova
Ā 
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache AiravataRESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
smarru
Ā 
Introduction to API
Introduction to APIIntroduction to API
Introduction to API
rajnishjha29
Ā 
Web Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptxWeb Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptx
PARDHIVANNABATTULA
Ā 
APIs at Scale with TypeSpec by Mandy Whaley, Microsoft
APIs at Scale with TypeSpec by Mandy Whaley, MicrosoftAPIs at Scale with TypeSpec by Mandy Whaley, Microsoft
APIs at Scale with TypeSpec by Mandy Whaley, Microsoft
Nordic APIs
Ā 
Content Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortalsContent Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortals
Axway
Ā 
Semantic Web Servers
Semantic Web ServersSemantic Web Servers
Semantic Web Servers
webhostingguy
Ā 
Online voting system ppt by anoop
Online voting system ppt by anoopOnline voting system ppt by anoop
Online voting system ppt by anoop
Anoop Kumar
Ā 
PRIME OOPSLA12 paper
PRIME OOPSLA12 paperPRIME OOPSLA12 paper
PRIME OOPSLA12 paper
Eran Yahav
Ā 
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Coen De Roover
Ā 
Automating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight SemanticsAutomating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight Semantics
mmaleshkova
Ā 
API Testing Interview Questions PDF By ScholarHat
API Testing Interview Questions PDF By ScholarHatAPI Testing Interview Questions PDF By ScholarHat
API Testing Interview Questions PDF By ScholarHat
Scholarhat
Ā 
Api design best practice
Api design best practiceApi design best practice
Api design best practice
Red Hat
Ā 
Crossing the chasm between ontology engineering and application development
Crossing the chasm between ontology engineering and application developmentCrossing the chasm between ontology engineering and application development
Crossing the chasm between ontology engineering and application development
Paola Espinoza-Arias
Ā 
Ibm_interconnect_restapi_workshop
Ibm_interconnect_restapi_workshopIbm_interconnect_restapi_workshop
Ibm_interconnect_restapi_workshop
Shubhra Kar
Ā 
API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)
Tom Johnson
Ā 
PPT for Seminar.pptx
PPT for Seminar.pptxPPT for Seminar.pptx
PPT for Seminar.pptx
Akshay Bhujbal
Ā 
Practices and tools for building better APIs
Practices and tools for building better APIsPractices and tools for building better APIs
Practices and tools for building better APIs
NLJUG
Ā 
Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)
Peter Hendriks
Ā 
Cross-Lingual Web API Classification
Cross-Lingual Web API ClassificationCross-Lingual Web API Classification
Cross-Lingual Web API Classification
mmaleshkova
Ā 
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache AiravataRESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
smarru
Ā 
Introduction to API
Introduction to APIIntroduction to API
Introduction to API
rajnishjha29
Ā 
APIs at Scale with TypeSpec by Mandy Whaley, Microsoft
APIs at Scale with TypeSpec by Mandy Whaley, MicrosoftAPIs at Scale with TypeSpec by Mandy Whaley, Microsoft
APIs at Scale with TypeSpec by Mandy Whaley, Microsoft
Nordic APIs
Ā 
Content Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortalsContent Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortals
Axway
Ā 
Semantic Web Servers
Semantic Web ServersSemantic Web Servers
Semantic Web Servers
webhostingguy
Ā 
Online voting system ppt by anoop
Online voting system ppt by anoopOnline voting system ppt by anoop
Online voting system ppt by anoop
Anoop Kumar
Ā 
Ad

More from Masud Rahman (20)

HereWeCode 2022: Dalhousie University
HereWeCode 2022: Dalhousie UniversityHereWeCode 2022: Dalhousie University
HereWeCode 2022: Dalhousie University
Masud Rahman
Ā 
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...
Masud Rahman
Ā 
PhD Seminar - Masud Rahman, University of Saskatchewan
PhD Seminar - Masud Rahman, University of SaskatchewanPhD Seminar - Masud Rahman, University of Saskatchewan
PhD Seminar - Masud Rahman, University of Saskatchewan
Masud Rahman
Ā 
PhD proposal of Masud Rahman
PhD proposal of Masud RahmanPhD proposal of Masud Rahman
PhD proposal of Masud Rahman
Masud Rahman
Ā 
PhD Comprehensive exam of Masud Rahman
PhD Comprehensive exam of Masud RahmanPhD Comprehensive exam of Masud Rahman
PhD Comprehensive exam of Masud Rahman
Masud Rahman
Ā 
Doctoral Symposium of Masud Rahman
Doctoral Symposium of Masud RahmanDoctoral Symposium of Masud Rahman
Doctoral Symposium of Masud Rahman
Masud Rahman
Ā 
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...
Masud Rahman
Ā 
ICSE2018-Poster-Bug-Localization
ICSE2018-Poster-Bug-LocalizationICSE2018-Poster-Bug-Localization
ICSE2018-Poster-Bug-Localization
Masud Rahman
Ā 
MSR2017-Challenge
MSR2017-ChallengeMSR2017-Challenge
MSR2017-Challenge
Masud Rahman
Ā 
MSR2017-RevHelper
MSR2017-RevHelperMSR2017-RevHelper
MSR2017-RevHelper
Masud Rahman
Ā 
STRICT-SANER2017
STRICT-SANER2017STRICT-SANER2017
STRICT-SANER2017
Masud Rahman
Ā 
MSR2015-Challenge
MSR2015-ChallengeMSR2015-Challenge
MSR2015-Challenge
Masud Rahman
Ā 
MSR2014-Challenge
MSR2014-ChallengeMSR2014-Challenge
MSR2014-Challenge
Masud Rahman
Ā 
CodeInsight-SCAM2015
CodeInsight-SCAM2015CodeInsight-SCAM2015
CodeInsight-SCAM2015
Masud Rahman
Ā 
STRICT-SANER2015
STRICT-SANER2015STRICT-SANER2015
STRICT-SANER2015
Masud Rahman
Ā 
CMPT-842-BRACK
CMPT-842-BRACKCMPT-842-BRACK
CMPT-842-BRACK
Masud Rahman
Ā 
RACK-Tool-ICSE2017
RACK-Tool-ICSE2017RACK-Tool-ICSE2017
RACK-Tool-ICSE2017
Masud Rahman
Ā 
RACK-SANER2016
RACK-SANER2016RACK-SANER2016
RACK-SANER2016
Masud Rahman
Ā 
QUICKAR-ASE2016-Singapore
QUICKAR-ASE2016-SingaporeQUICKAR-ASE2016-Singapore
QUICKAR-ASE2016-Singapore
Masud Rahman
Ā 
CORRECT-ToolDemo-ASE2016
CORRECT-ToolDemo-ASE2016CORRECT-ToolDemo-ASE2016
CORRECT-ToolDemo-ASE2016
Masud Rahman
Ā 
HereWeCode 2022: Dalhousie University
HereWeCode 2022: Dalhousie UniversityHereWeCode 2022: Dalhousie University
HereWeCode 2022: Dalhousie University
Masud Rahman
Ā 
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...
Masud Rahman
Ā 
PhD Seminar - Masud Rahman, University of Saskatchewan
PhD Seminar - Masud Rahman, University of SaskatchewanPhD Seminar - Masud Rahman, University of Saskatchewan
PhD Seminar - Masud Rahman, University of Saskatchewan
Masud Rahman
Ā 
PhD proposal of Masud Rahman
PhD proposal of Masud RahmanPhD proposal of Masud Rahman
PhD proposal of Masud Rahman
Masud Rahman
Ā 
PhD Comprehensive exam of Masud Rahman
PhD Comprehensive exam of Masud RahmanPhD Comprehensive exam of Masud Rahman
PhD Comprehensive exam of Masud Rahman
Masud Rahman
Ā 
Doctoral Symposium of Masud Rahman
Doctoral Symposium of Masud RahmanDoctoral Symposium of Masud Rahman
Doctoral Symposium of Masud Rahman
Masud Rahman
Ā 
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...
Masud Rahman
Ā 
ICSE2018-Poster-Bug-Localization
ICSE2018-Poster-Bug-LocalizationICSE2018-Poster-Bug-Localization
ICSE2018-Poster-Bug-Localization
Masud Rahman
Ā 
MSR2017-Challenge
MSR2017-ChallengeMSR2017-Challenge
MSR2017-Challenge
Masud Rahman
Ā 
MSR2017-RevHelper
MSR2017-RevHelperMSR2017-RevHelper
MSR2017-RevHelper
Masud Rahman
Ā 
STRICT-SANER2017
STRICT-SANER2017STRICT-SANER2017
STRICT-SANER2017
Masud Rahman
Ā 
MSR2015-Challenge
MSR2015-ChallengeMSR2015-Challenge
MSR2015-Challenge
Masud Rahman
Ā 
MSR2014-Challenge
MSR2014-ChallengeMSR2014-Challenge
MSR2014-Challenge
Masud Rahman
Ā 
CodeInsight-SCAM2015
CodeInsight-SCAM2015CodeInsight-SCAM2015
CodeInsight-SCAM2015
Masud Rahman
Ā 
STRICT-SANER2015
STRICT-SANER2015STRICT-SANER2015
STRICT-SANER2015
Masud Rahman
Ā 
CMPT-842-BRACK
CMPT-842-BRACKCMPT-842-BRACK
CMPT-842-BRACK
Masud Rahman
Ā 
RACK-Tool-ICSE2017
RACK-Tool-ICSE2017RACK-Tool-ICSE2017
RACK-Tool-ICSE2017
Masud Rahman
Ā 
RACK-SANER2016
RACK-SANER2016RACK-SANER2016
RACK-SANER2016
Masud Rahman
Ā 
QUICKAR-ASE2016-Singapore
QUICKAR-ASE2016-SingaporeQUICKAR-ASE2016-Singapore
QUICKAR-ASE2016-Singapore
Masud Rahman
Ā 
CORRECT-ToolDemo-ASE2016
CORRECT-ToolDemo-ASE2016CORRECT-ToolDemo-ASE2016
CORRECT-ToolDemo-ASE2016
Masud Rahman
Ā 
Ad

Recently uploaded (20)

Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
Ā 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
Ā 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
Ā 
BỘ ĐỀ TUYỂN SINH VƀO LỚP 10 TIįŗ¾NG ANH - 25 ĐỀ THI BƁM SƁT Cįŗ¤U TRÚC MỚI NHįŗ¤T, ...
BỘ ĐỀ TUYỂN SINH VƀO LỚP 10 TIįŗ¾NG ANH - 25 ĐỀ THI BƁM SƁT Cįŗ¤U TRÚC MỚI NHįŗ¤T, ...BỘ ĐỀ TUYỂN SINH VƀO LỚP 10 TIįŗ¾NG ANH - 25 ĐỀ THI BƁM SƁT Cįŗ¤U TRÚC MỚI NHįŗ¤T, ...
BỘ ĐỀ TUYỂN SINH VƀO LỚP 10 TIįŗ¾NG ANH - 25 ĐỀ THI BƁM SƁT Cįŗ¤U TRÚC MỚI NHįŗ¤T, ...
Nguyen Thanh Tu Collection
Ā 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
Ā 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
Ā 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
Ā 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
Ā 
APM Midlands Region April 2025 Sacha Hind Circulated.pdf
APM Midlands Region April 2025 Sacha Hind Circulated.pdfAPM Midlands Region April 2025 Sacha Hind Circulated.pdf
APM Midlands Region April 2025 Sacha Hind Circulated.pdf
Association for Project Management
Ā 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
Ā 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
Ā 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
Ā 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
Ā 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
Ā 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
Ā 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
Ā 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
Ā 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
Ā 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
Ā 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
Ā 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
Ā 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
Ā 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
Ā 
BỘ ĐỀ TUYỂN SINH VƀO LỚP 10 TIįŗ¾NG ANH - 25 ĐỀ THI BƁM SƁT Cįŗ¤U TRÚC MỚI NHįŗ¤T, ...
BỘ ĐỀ TUYỂN SINH VƀO LỚP 10 TIįŗ¾NG ANH - 25 ĐỀ THI BƁM SƁT Cįŗ¤U TRÚC MỚI NHįŗ¤T, ...BỘ ĐỀ TUYỂN SINH VƀO LỚP 10 TIįŗ¾NG ANH - 25 ĐỀ THI BƁM SƁT Cįŗ¤U TRÚC MỚI NHįŗ¤T, ...
BỘ ĐỀ TUYỂN SINH VƀO LỚP 10 TIįŗ¾NG ANH - 25 ĐỀ THI BƁM SƁT Cįŗ¤U TRÚC MỚI NHįŗ¤T, ...
Nguyen Thanh Tu Collection
Ā 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
Ā 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
Ā 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
Ā 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
Ā 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
Ā 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
Ā 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
Ā 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
Ā 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
Ā 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
Ā 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
Ā 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
Ā 

API Usage Pattern Extraction using Semantic Similarity

  • 1. SEMANTIC NETWORK BASED API USAGE PATTERN EXTRACTION & LEARNING Mohammad Masudur Rahman [email protected] Department of Computer Science University of Saskatchewan
  • 2. PRESENTATION OVERVIEW Introduction ļ‚¢ Motivating Example ļ‚¢ Background Concepts ļ‚¢ Proposed Approach ļ‚¢ Semantic Network of Source code ļ‚¢ API Usage Pattern Extraction ļ‚¢ Pattern Learning & Visualization ļ‚¢ Experimental Results & Discussions ļ‚¢ Threats to Validity ļ‚¢ Conclusion & Future Works ļ‚¢
  • 3. INTRODUCTION API (Application Programming Interface) Libraries ļ‚¢ API Documentation, API Browser, forums ļ‚¢ API Usage learning for developers ļ‚¢ Existing projects using APIs ļ‚¢ API Usage Patterns ļ‚¢
  • 4. WHAT IS API USAGE PATTERN? A frequent and consistent sequence of API method calls and field accesses ļ‚¢ Performs a particular programming task. ļ‚¢ Widely used in multiple projects ļ‚¢ Widely accepted by developers community ļ‚¢
  • 6. BIG QUESTION? How to extract the API usage patterns from the source code?
  • 7. SEMANTIC WEB OR NETWORK ļ‚¢ What is the living place of the author of a particular software manual?
  • 10. RESEARCH QUESTIONS RQ 1: Can semantic network technologies represent the semantics of OO source code properly? ļ‚¢ RQ 2: Can this representation be used for API usage pattern extraction and learning? ļ‚¢
  • 11. BACKGROUND CONCEPTS API Usage Patterns ļ‚¢ API Usage Violation & Anomalies ļ‚¢ Semantic Web ļ‚¢ Semantic Network of Source Code ļ‚¢ Resource Description Framework (RDF) ļ‚¢ RDF Statement or Triples ļ‚¢
  • 12. RDF TRIPLE (BUILDING BLOCK OF SEMANTIC WEB OR NETWORK) Subject Predicate Object
  • 13. PROPOSED APPROACH FOR API USAGE PATTERN EXTRACTION & LEARNING
  • 14. PROPOSED APPROACH FOR API USAGE PATTERN EXTRACTION & LEARNING 1 API Class List API Classes 3 4 Yes Contains API ? 2 OSS Projects Parsed Expressions Source files Source code parser 5 Semantic Network Builder RDF Files 7 6 No Patterns API Usage Pattern Manager Pattern 9 Pattern Source Skeleton Builder Pattern 8 RDF Pattern Visualizer API Pattern Explorer
  • 15. SOURCE CODE SEMANTIC NETWORK Java Source code AST Parser (Javaparser) API Expression selection rules Apache Jena Framework Java Expressions RDF Maker RDF Network RDF Triples
  • 16. API USAGE PATTERN EXTRACTION Common Sub-graph Selection Candidate API usage Patterns All Usages of an API Class Yes Selected API Usage Patterns Pattern Score > threshold ? No Discarded
  • 17. EXPERIMENTAL RESULTS 25 Open source Projects ļ‚¢ 3 API libraries (java.io, java.util, java.awt) ļ‚¢ 250 API classes selected ļ‚¢ API usages found for 113 API classes ļ‚¢ Pattern found for 76 API classes ļ‚¢ Total 776 patterns ļ‚¢
  • 19. SOURCE CODE SKELETON Fig: BufferedInputStream Usage Pattern
  • 20. EXPERIMENTAL RESULTS Project #Class #M &C #ATCF #ADCF #ATPF #ADPF Ant-Contrib 186 1388 96 23 1865 280 AOI 461 6489 218 55 1651 494 Groimp 1202 13875 132 41 1632 407 JFreechart 1059 12368 507 38 6841 410 JHotdraw7 689 7330 310 49 2547 462 #M & C =Methods & Constructors, #ATCF=Total API class, #ADCF=Distinct API class, #ATPF=Total API Patterns found, #ADPF=Distinct API Patterns found
  • 21. PATTERNS PER CLASS Fig: # patterns extracted per class comparison
  • 22. RESULTS DISCUSSION RQ 1: Can semantic network technologies represent the semantics of OO source code properly? ļ‚¢ Graph-based API Usage Extraction by Nguyen et al, FSE, 2009 : Incomplete semantics for edges and attributes ļ‚¢ Source code ontology by Wursch et al, ICSE, 2010 : Does not represent the complete source code ļ‚¢ The proposed approach captures expression level syntax and semantics ļ‚¢ Focuses on API usage patterns ļ‚¢
  • 23. RESULTS DISCUSSION RQ 2: Can this representation be used for API usage pattern extraction and learning? ļ‚¢ Successfully extracts 776 patterns for 76 API classes from 25 open source projects ļ‚¢ A potential approach to be explored more for API usage pattern exploration ļ‚¢ Visualization of RDF network helps in learning ļ‚¢ Source code as visual entities rather than lines ļ‚¢ More comprehensive idea about OO source code ļ‚¢ Applicable for complex OO relationships ļ‚¢ Very useful for quick learning ļ‚¢
  • 24. THREATS TO VALIDITY Representing complete semantics: a non-trivial task. ļ‚¢ More expressions for more accurate representation ļ‚¢ RDF pattern visualization within limited display ļ‚¢ Need to be introduced with RDF convention ļ‚¢
  • 25. CONCLUSION & FUTURE WORKS Applicability of semantic web technologies for API usage pattern extraction ļ‚¢ Semantic representation for learning by the developers ļ‚¢ Real world user study ļ‚¢ Extracted patterns for automatic code completion in the IDE. ļ‚¢ Extracted patterns for API violation and anomaly detection ļ‚¢
  • 27. REFERENCES [1] Semantic web diagram.URL http://www.w3.org/ Talks/2002/10/16-sw/slide7-0.html. [2] Tung Thanh Nguyen, Hoan Anh Nguyen, NamH.Pham, JafarM.Al-Kofahi, and TienN.Nguyen. Graph-based mining of multiple object usage patterns. In Proc. ESEC/FSE, 2009, pages 383-392. [3] M.Wursch, G.Ghezzi, G.Reif,and H.C.Gall. Supporting developers with natural language queries. In Proc. ICSE, 2010,pages 165-174 [4] Tao Xie and Jian Pei. Mapo:mining api usages from open source repositories. In Proc. MSR, 2006, pages 574-57 [5] Semantic web technology.URL http://www.w3.org/ 2001/sw [6] Visual learning style.URL http://www.learning-styles-online.com/style/visualspatial. [7] Apache Jena framework.URL http://jena.apache.org/. [8] Javaparser-java 1.5 parser and ast.URL http://code.google.com/p/javaparser/. [9] RDF-gravity tool.URL http://semweb.salzburgresearch.at/apps/rdf-gravity/.

Editor's Notes

  • #2: Hello everybodyWelcome to my presentationThis is Masudur RahmanToday I am going to present my research project titled as ā€œSemantic network based API usage pattern extraction and learningā€Hope you will enjoy the presentation
  • #3: In my presentation I am going to cover the following topics.
  • #4: API or Application programming interface is an interesting concept in modern OO programming languages as it encourages to reuse the existing programming resources without reinventing the wheels.But it is tough for the developer to master the APIs when there are a good number of complex APIs involved and there is no sufficient help to learn how to use those APIs. For example, we can mention API documentation, forum or API browser; however, they are not good enough to meet the developer’s learning need as they contain some simple examples or troubleshooting information. So, one possible solution is-consulting existing projects by other developers. Those projects have used the APIs and can provide some practical examples of the usage.However, we can not capture the whole API usage, rather we need to extract the API usage pattern which can provide sufficient knowledge of how to use an API.Here comes the term -API usage pattern
  • #5: Now the question is- what is an API usage pattern?When a frequent and consistent sequence of API method calls and field accesses perform a particular programming task, then that sequence is called API usage pattern.It has to be widely used in different projectsIt has to be widely accepted by the developers community
  • #6: For example, this is a code example for reading content from a file. From our research, we found that it is a common and frequent sequence of API calls to read the file content in numerous projects.It contains calls involved with Scanner class.So, it can be considered as a API usage pattern for Scanner API class.We are interested to extract such type of usage patterns for different API classesfrom different open source projects so that developer can learn them and use them in their works.
  • #7: From our research, we got there are two board ways for API usage pattern extraction.Frequent method sequence miningGraph-based approachIn our research, we are following a relatively novel approach for API usage pattern extraction.We are using semantic web technologies.Ok lets explain the semantic web technologies.
  • #8: Besides API usage pattern the most important concept needs to be explained is semantic web or network.Semantic web is a new breed of world wide web found by Tim Berners Lee. It consists of nodes and meaningful connecting edges which are not like simple hyperlinks rather they contains meaningful information. And each node is called a resource which can be a document, person, image, song or anything that can be identified by a REST URI in the web.Basically, semantic web is an efficient tool for knowledge representation and inference. For example, this is a simple semantic network representing some knowledge. Here, from the network, we can retrieve the living place information of a person written a particular software manual. This is easy for semantic web but relatively hard for current structure of www.We are interested to apply this kind of structure to capture the source code knowledge and use it for API usage pattern extraction and learning.
  • #9: Let us consider a new developer has some knowledge about OO programming and he is assigned to fix a problem that involves complex API.He has to understand and learn the API to use in the work. Here is the example that opens a file and read the content of a file.The code is simple and contains two object usage – Scanner and File.But, the developer’s understanding about the source code depends on his knowledge about Java syntax and he has to grab the concepts from some source code lines which is not always easy, quick or helpful.
  • #10: But if you consider this one, does it make sense?This is a semantic network version of the source code example I just showed. We, people are really visual beings and we understand relationships more easily from graphics or structures rather than texts. It looks a bit colorful, but a mediocre developer can understand the OO relationships between two objects without being concerned about the java syntax. For example, developer can understand the relationship between Scanner and File object. For example, here it shows that File is a parameter to the constructor of Scanner object. Similarly, other relationships can be represented like hasMethod, hasChild, hasContstructor can be in a simple graphical way.So, basically this type of representation of source code is really can help in understanding and learning for the developer.Also the structure can reflect the semantics and relationship among different source code entities like class, method, object, instances in a novel way which can be manipulated for API usage pattern extraction.Thus it is helpful for our research goal and we are motivated to use semantic network of source code for the research.
  • #11: In this research, we try to answer these two research questions.RQ 1: Can semantic network technologies represent the semantics of OO source code properly?RQ 2: Can this representation be used for API usage pattern extraction and learning?
  • #12: Here are some background concepts that we have explained so far. However, now we will discuss about the RDF, the framework used to implement the Semantic web or network.
  • #13: However, semantic web is implemented using a framework called Resource Description Framework (RDF).The building block of RDF network is RDF statement or triples. Each statement represent a fact or a piece of knowledge about the network or system.Each triple has 3 components – subject, predicate and object.Subject: the entity about which the fact is described.Predicate: the attribute of the subjectObject: the attribute values of the subject.For example, Scanner.new is a node which type is a constructor.
  • #15: Now comes the proposed approach for API usage pattern extraction and learning.At first we selected 25 open source projects and a list of API classes from 3 standard java libraries. Then we look for each java class from the open source projects for the API usages? We consider the java methods or constructors as the containers of the API usages. So, we extract them and parse them using AST parser provided by Eclipse.After parsing, we used the selected expression to develop the semantic network of source code that can be considered as an equivalent graphical representation of source code. Then we used those usage graphs to extract the API usage patterns.However, this is some overview, now, we describe some important steps more deeply.
  • #16: Representing source code into equivalent semantic network. It is obviously a challenging task. However, we figured out a way to do that.Java source code is parsed by the AST parser provided by Eclipse. We parsed each Java statement up to expression level and got numbers of expression that express the semantics. However, in this research we are concerned with API usage patterns; so, we mainly focused on the expressions that reflect the OO semantics such as method call expression, field access expression, object creation expression and so on.We also used an advanced framework to deal with RDF technologies called Jena by Apache and thus we used all three – expression, selection rules, predicate list and Jena to develop the RDF network of each API usage.Basically, we developed the triples that contain those three parts – subject, predicate and object to represent every fact about the source code semantics and knowledge. Each semantic network is formed based on those triples. Thus, we got an equivalent semantic network for each API usage in the source code.Question is why do we need to represent the source in this way? Answer: Analyzing and processing source code directly is not easy. So, we need a structure which can be programmatically manipulated. Semantic web like structure provides more strength with its reasoning power through SPARQL.
  • #17: Now comes the API usage pattern extraction from the RDF API usages.Basically, we exploited the strength of Jena framework for this purpose. From a list of usage graphs, we extracted all possible common subsets that capture the API calls, object creation, field access and all other API related information. These subsets are the isomorphic sub-graphs of each other and the possible candidates for the API usage patterns.However, then we calculated the score of each pattern candidate based on their frequency in the same project and frequency in multiple projects. Then, based on some thresholds, we considered a candidate pattern as a selected pattern for an API class.
  • #18: Now comes the experimental results.We used 25 open source projects from different domains like java graphics, image manipulation, networking, domain management, utilities etc.We chose 3 standard API libraries and 250 classes from them.We detected the usages of 113 classes in those projects, however, we are able to extract patterns for 76 API classes.In total, we extracted 776 distinct patterns.
  • #19: From our experiment, we extracted this type of usage patterns from the API usage.For example, this is an API usage pattern for BufferedInputStream API class. It is a sub-graph of the total API usage.This sub-graph of sub-network tells us how to create an object of a BufferedInputStream object.Create a File object and use it as a parameter to the constructor of FileInputStream.The use that FileInputStream object to construct the BufferedInputStream object.
  • #20: While the semantic representation can be used for learning and understanding, it can also converted into the corresponding source code skeleton.So, basically, this is the source code version of the API usage patterns and it also represent the same information as the network does.For this task, we actually parsed the semantic network, that means the triples to generate the code skeletons which can be helpful for the developer in writing the actual code.
  • #21: Here is the table that shows a portion of our results.For example, JHotdraw7 is a commonly used java project for different software maintenance activities.We found 689 java classes, 7330 methods and constructors49 API classes are found in the project and 2547 patterns are used.However, 462 distinct patterns are extracted We applied the experiments on 25 projects and we found our approach quite promising in extracting the API usage patterns.
  • #22: We compared our results with the results of Nguyen et al, FSE, 2009.We considered top 5 projects based on their size and API patterns found.The graph shows average no. of patterns found per project class file. Here, we can see that our approach shows better performance in case of 3 projects. Also we notice a regular pattern in our results which is absent the Nguyen’s approach.Basically, we checked those last 3 projects and found they are highly popular and active in real world. Additionally, we found that they are involved with more API usages than other projects. So, we can also infer that advanced and frequent API usage may be a possible cause for their popularity.Though, we used a different set of projects than Nguyen et al, we found an interesting correlation between these two set of results.Thus, it is reasonable to think that the proposed approach is a suitable candidate for API usage pattern extraction. However, we are working on to make it more efficient.
  • #23: Now comes about the answers of the research questions we stated at the very beginning.RQ 1: Can semantic network technologies represent the semantics of OO source code properly?Existing work by Nguyen et al uses a graph-based approach but the source code representation was not completely semantic as the connecting edges were treated too abstractly such as data dependency or control dependency, but our approach decomposes that relationships and dependency into more granular level and more importantly, ours one can be used for knowledge inference.Existing work by Wursch et al develops the source code ontology, but that is not a proper representation of source code, rather it contains partial information about the source code.So none of the existing works actually convert the source code into a semantic representation this much. Our approach can capture the semantics of OO source code more broadly than existing approaches.
  • #24: RQ 2: Can this representation be used for API usage pattern extraction and learning?Yes, the semantic representation is quite helpful for API usage pattern extraction as we have already did that.Moreover, this representation is found as a potential approach for learning API by the developers because of its visual and descriptive logic nature.Basically, we try to add a novel concept for API learning and understanding.We are still working on it and this current outcome can be considered as a preliminary results of the whole idea.
  • #25: While working, we faced few challenges which we tried to overcome.The complete semantic representation is a non-trivial task as it involves too many expression of a complete programming language. In this research, we tried to capture the OO features/concepts of Java as we focused on API usage patterns. But if more expressions are considered, more accurate representation is possible.We also found that RDF visualization within a limited display is challenging.
  • #26: So, we proposed a new approach for representing OO source code in a semantic network fashion which is helpful forAPI usage pattern extraction, learning and visualization.More importantly, it capture the source code semantics than existing graph based approaches.This research also leads us to further research problem and we have some future plans:We will conduct a real world user study to determine its real benefitsWe will apply the extracted API usage patterns for code completion in the Eclipse IDEAlso will be used for API usage violation or anomaly detection.
  • #27: That’s all about my presentation.Thanks to everybody.