SILPA Webservice APIs

Introduction

Silpa provides a set of webservice APIs over json-rpc protocol. Silpa services can be used from any programming language which has an RPC implementation. The request and response formats of APIs are in json. It is recommended to read the json-rpc documentation if you are not familiar with that.

This page explains the available usage and sample usage from python application. Implementing this in other programming languages should not be difficult and should be a matter of changing the programming language syntax For further assistance, see the related links section of this page

For using the APIs you need the jsonrpc library of python. You can get this from here.

Concepts

JSON-RPC wraps an object, allowing you to call methods on that object and get the return values. It also provides a way to get error responses.

The specification goes into the details (though in a vague sort of way). Here’s the basics:

Available Services

Silpa provides a service discovery APIs to get the list of available service APIs. The following code illustrates the usage:

# -*- coding: utf-8 -*-
from jsonrpc import ServiceProxy
silpaService = ServiceProxy("http://smc.org.in/silpa/JSONRPC")
print silpaService.system.listMethods()

When the above code is executed you should get a response like this:

['modules.CharDetails.getdetails', 'modules.Dictionary.getdef', 'modules.Fortune.fortune_ml', 
'modules.LangGuess.getScriptName', 'modules.LangGuess.guessLanguage', 'modules.Payyans.ASCII2Unicode',
'modules.Payyans.ASCII2Unicode', 'modules.Payyans.Unicode2ASCII', 'modules.Payyans.Unicode2ASCII',
'modules.Soundex.compare', 'modules.Soundex.soundex','modules.Syllabalizer.syllabalize',
'modules.Transliterator.transliterate']

As you can see the response is a json formatted list of available methods available in the server

Dictionary

Dictionary APIs provide dictionary lookup service. Sample usage is given below
print silpaService.modules.Dictionary.getdef("help","freedict-eng-hin")
Response will be the string containing the definition of the given word

Spellcheck

Spellcheck API provides langauge independent spellchecking service across Indian languages and English Sample usage is given below.
>>>print silpaService.modules.Spellchecker.check("speling")
False
>>>print silpaService.modules.Spellchecker.check("speling","en_US")
False
>>>print silpaService.modules.Spellchecker.suggest("speling")
["spelling","spieling","spewing"]
The language parameter is optional. If not provided the language of the input word will be detected.

Soundex

This service provides indic soundex algorithm based soundex codes for a word Sample usage is given below.
>>>print silpaService.modules.Soundex.soundex("കാര്‍ത്തിക്")
കAPKKBF0
>>>print silpaService.modules.Soundex.compare("കാര്‍ത്തിക്","கார்திக்")
2

Ngram

This service provides indic ngram libraries