API-Application Programming Interface

30
API-Application Programming Interface Presented By: Konkani NLP Team Goa University 

Transcript of API-Application Programming Interface

API-Application Programming Interface

API-Application Programming InterfacePresented By:Konkani NLP Team Goa University

Brief OutlineAPIsIndoWordNet APILayers of APISample API codes

APIsAn Application Programming Interface (API) is a set of commands, functions and protocols which programmers can use when building a software.

It allows the programmers to use predefined functions to interact with systems, instead of writing them from scratch.

Characteristics of good APIEasy to learn and use, Hard to misuse.Easy to read and maintain code that uses it.Is programming language neutral.Sufficiently powerful to support all computational requirements.

IndoWordNet Database Design3IndoWordNet APIIt allows a user to access wordnet database and to create wordnet tools without the knowledge of the underlying database design.

The API is object-oriented design.

The API is designed in such a way that it supports single/ multiple languages.

The API is designed in two layers:Application layerDatabase layer

IndoWordNet Database Design4

Implementation of APIs is done in:

JAVA

Php

Database layerThe Database layer deals with encapsulation of the database design.

It provides a standard interface to the application layer.

The Database layer supports all the operations needed to be performed on the database.

IndoWordNet Database Design6Database Layer consists of the following classes:IWDbA class that connects to the Database.

IWConA class that sets up a connection to a database

IWStatementA class which contains all the queries pertaining to the application layerAlso the basic functions such as updating, deletion, insertion, selection, etc.

IWResultA class which returns results to the application layer, the results of executed queries

IndoWordNet Database Design7Application layerThe Application layer incorporates the logical part of the IndoWordNet requirements, so as to provide classes and objects to perform all the operations to be performed on the synset, relations, ontology, other master data, etc.

The Application Layer allows us to perform operations such as:get all the synsets get all wordsget all synsets from a given start id to a given end idget various relations for a given synset/ wordget words for a given synset add a new source or domain, a new relationto create sysnet, to create words,update the records in the tabledelete a synset/ source/ domainmodify ontology informationEtc

IndoWordNet Database Design8Application Layer consists of the following classes:

IWAPIClassA class that allows to initialise API library for use.Maintain master tables.Manage connectivity to language specific databases.

IWSynsetA class that represents a Synset

IWWordA class that represents a Word

IWSynsetCollectionCollection of Synsets

IWWordCollectionCollection of words for a synset

IWOntologyA class that represents OntologyEach synset is mapped into some place in the ontology tree

IndoWordNet Database Design9IWOntologyCollectionCollection of child nodes for a given onto node

IWExampleCollectionCollection of examples

IWFileA class that represents a File

IWDataFileA class that represents a data file

IWPictureFileA class that represents a picture files

IWFileCollectionCollection of files

IndoWordNet Database Design10Where to copy the API sample codesFor java:

Open the sampleCodesInJava folder in Netbeans and import the libraries from the lib folder.

For Php:Copy the sampleCodesInPhp Folder in htdocs and open it in Netbeans

IndoWordNet Database Design11IWAPIClass A class that allows initialising API library for use,Maintains master tables,Manage connectivity to language specific databases,A class that allows to get all synsets from the database, It consists of all the language database names, the various antonymy property values, meronymy_holonymy property values, etc...To create new synsets,To get synsets belonging to a domain,To get synset belonging to a grammatical category,To get synsets belonging to a given source,To get synsets for a given range of Ids,To get all files,To create a new word, new source, new domain, new category, etcTo destroy a synset, word, relation,EtcThe object of the IWAPIClass is declared as follows:

In Java: IWAPIClass apiObject = new IWAPIClass("root", ""); IWDb dbObj = apiObject.connectLanguageDb(IWAPIClass.KONKANI);

In Php:$apiObject = new IWAPIClass("root", ""); $dbObj = $apiObject->connectLanguageDb(IWAPIClass::$KONKANI);

Where root is the username of the database, password is . It will connect to the master database. IWSynset A class that represents a Synset.

To get the concept, translated concept, transliterated concept of a given synset which is present in the database.

To get words and relations of a given synset.

To get examples belonging to a synset.

To get the category, domain, source, concept of a given synset present in the database.

To add examples, files and various semantic relations to a synset.

To remove semantic relations.

To set a new concept, a new category, a new domain for a synset.

Etc

The object of the IWSynset is declared as follows:

In Java:IWSynset synsetObject = new IWSynset (dbObject, synset_id);

In Php:$synsetObject = new IWSynset ($dbObject, $synset_id);IWSynsetCollection A class that represent a Collection of Synset.

To get the length of the collection i.e the number of synsets present in the collection, use length();

To get the first element from the collection, the next element from the collection, the previous element from the collection and the last element from the collection, use first(); next(); previous(); last(); respectively.

To get the current element, use getElement();

IWWord A class that represents a Word.

To get various lexical relation such as antonymy relation, compounding relation, gradation relation, etc.

To get all the synsets for a given word.

To get the lex id.

To remove lexical relations for specified synset and word.

Etc

IWWordCollection A class that represent a Collection of words for a synset.

To get the length of the collection i.e the number of words present in the collection, use length();

To get the first element from the collection, the next element from the collection, the previous element from the collection and the last element from the collection, use first(); next(); previous();and last(); respectively.

To get the current element, use getElement();

IWExampleCollection

Collection of examples for a synset. To get the length of the collection i.e the number of examples present in the collection, use length();

To get the first element from the collection, the next element from the collection, the previous element from the collection and the last element from the collection, use first(); next(); previous();and last(); respectively.

To get the current element, use getElement();

IWOntology

A class that represents Ontology node.

Each synset is mapped into some place in the ontology tree.

To get ontology Id, use getOntologyID();

To get ontology data, ontology translated data, ontology transliterated data, use getOntologyData(); getOntologyTranslatedData(); and getOntologyTransliteratedData();

To get ontology description, ontology translated description, ontology transliterated description, use getOntologyDescription(); getOntologyTranslatedDescription(); and getOntologyTransliteratedDescription();

To set ontology data, ontology translated data, ontology transliterated data, use setOntologyData(); setOntologyTranslatedData(); and setOntologyTransliteratedData();

To set ontology description, ontology translated description, ontology transliterated description, use setOntologyDescription(); setOntologyTranslatedDescription(); and setOntologyTransliteratedDescription();

Etc

IWOntologyCollection Collection of child nodes for a given onto node.

To get the length of the collection i.e the number of ontology nodes present in the collection, use length();

To get the first element from the collection, the next element from the collection, the previous element from the collection and the last element from the collection, use first(); next(); previous();and last(); respectively.

To get the current element, use getElement();

IWFile A class that represents Files.

To get the file content, to get the file Id, to get file size, to get file type.

To set a new file type, to set a new file name.

Etc...

IWFileCollection Collection of files.

To get the length of the collection i.e the number of files in the collection, use length();

To get the first element from the collection, the next element from the collection, the previous element from the collection and the last element from the collection, use first(); next(); previous();and last(); respectively.

To get the current element, use getElement();

IWAntonymyCollection

Collection of words belonging to a synset having antonymy relation for a given synset and lex words.

To get the length of the collection i.e the number of antonymy relation for a given synset and lex word present in the collection, use length();

To get the first element from the collection, the next element from the collection, the previous element from the collection and the last element from the collection, use first(); next(); previous(); and last(); respectively.

To get the current element, use getElement();

To get anto word and anto synset use getAntoWord(); and getAntoSynset(); respectively.

To get the antonymy property value, use getAntonymyValue();

IWGradationCollection

A collection of gradation relation obtained for a given synset and lex words.

To get the gradation property for a given synset and lex words, use getGradationValue();

To get the length of the collection i.e the number of gradation relation for a given synset and lex word present in the collection, use length();

To get the first element from the collection, the next element from the collection, the previous element from the collection and the last element from the collection, use first(); next(); previous(); and last(); respectively.

To get the current element, use getElement();

To get the mid lex word and to get the last lex word use getMidLexWord(); and getLastLexWord(); respectively.

To get the mid synset and to get the last synset use getMidSynset(); and getLastSynset(); respectively.

IWLexicalRelationCollectionCollection of Lexical relation for a given word.

The different types of lexical relations are: antonymy (opposites), gradation, compounding, conjunction, etc.

To get the length of the collection using length();

To get the first element from the collection, the next element from the collection, the previous element from the collection and the last element from the collection, use first(); next(); previous(); and last(); respectively.

To get the current element, use getElement();

To get the lex word and synset id, use getLexWord(); and getSynsetID() respectively.

IWMeroHoloCollectionCollection of Meronymy Holonymy relation for a given synset.

To get the Meronymy_holonymy property value, use getMeroHoloValue();

To get the length of the collection using length();

To get the first element from the collection, the next element from the collection, the previous element from the collection and the last element from the collection, use first(); next(); previous(); and last(); respectively.

To get the current element, use getElement();

IWNounVerbLinkCollectionCollection of NounVerbLink relation for a given synset.

To get the link property value getLinkValue();

To get the length of the collection using length();

To get the first element from the collection, the next element from the collection, the previous element from the collection and the last element from the collection, use first(); next(); previous(); and last(); respectively.

To get the current element, use getElement();

To get NounVerbSynsetId, use getNounVerbSynsetID();

Questions?IndoWordNet Database Design29THANK YOUIndoWordNet Database Design30