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

http://swoogle.umbc.edu/SimService/GetSimilarity?operation=api&phrase1=XXX&phrase2=YYY

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.

http://swoogle.umbc.edu/SimService/GetSimilarity?operation=api&phrase1=car&phrase2=bike

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.

http://swoogle.umbc.edu/SimService/GetSimilarity?operation=api&phrase1=fire_VB&phrase2=dismiss_VB
http://swoogle.umbc.edu/SimService/GetSimilarity?operation=api&phrase1=fire_NN&phrase2=dismiss_VB

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.

http://swoogle.umbc.edu/SimService/GetSimilarity?operation=api&phrase1=fire_VB&phrase2=dismiss_VB&corpus=gigawords&type=concept


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)

http://swoogle.umbc.edu/StsService/GetStsSim?operation=api&phrase1=a%20small%20violin%20is%20being%20played%20by%20a%20girl&phrase2=a%20child%20is%20performing%20on%20a%20tiny%20instrument


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'):
    try:
        response = get(sss_url, params={'operation':'api','phrase1':s1,'phrase2':s2,'type':type,'corpus':corpus})
        return float(response.text.strip())
    except:
        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.