We have a simple Web API that can be used to query the UMBC Semantic Similarity service. Given two words or phrases it returns a string representing a number between 0.0 and 1.0. Call it using a a URL like the following


Where XXX and YYY are the urlencoded words or short noun or verb phrases you want to compare. For example, to compare the words car and bike with the URL.


You can also specify part of speech tag to your terms by appending them with _NN (noun), _VB (verb), _JJ (adj) or _RB (adv), as in the following examples.


The API supports two additional optional parameters: corpus and type which allow you to choose which corpus (e.g., webbase or gigawords) and which type of semantic similarity to use (e.g., concept or relation), as in the following example.


To compare Semantic Textual Similarity (STS) between two strings "A small violin is being played by a girl" and "a child is performing on a tiny instrument", you can use the following URL (note that the service name is different from the api above)


You can call the service easily from a program. Here's an example showing how to do it in Python.

from requests import get

sss_url = "http://swoogle.umbc.edu/SimService/GetSimilarity"

def sss(s1, s2, type='relation', corpus='webbase'):
        response = get(sss_url, params={'operation':'api','phrase1':s1,'phrase2':s2,'type':type,'corpus':corpus})
        return float(response.text.strip())
        print 'Error in getting similarity for %s: %s' % ((s1,s2), response)
        return 0.0

If you use this service in your research, we would appreciate citing it using the following paper, which descibes the approach behind the service.

Lushan Han, Abhay L. Kashyap, Tim Finin, James Mayfield and Johnathan Weese, UMBC_EBIQUITY-CORE: Semantic Textual Similarity Systems, Proc. 2nd Joint Conf. on Lexical and Computational Semantics, Association for Computational Linguistics, June 2013.