Skip to main content

Similar Terms

Many times you may need to find terms that have a similar meaning to another term. A few examples:

  • You've implemented a document editing interface and want to recommend alternative wordings to the user.
  • You're trying to group product listings by similar attributes, some users either don't add tags or use different but synonymous tags.
  • You're trying to optimize ad copy and want to try replacing some words with possibly catchier alternatives.

In these cases, it can be helpful to look for similar terms. The usual method for this is by using a thesaurus. Sapling offers this capability along with semantic matching to find similar terms that a thesaurus would miss.

You can test out this endpoint at our utilities page as well:

Try it out

Similar Terms POST

Sample Code

curl -X POST https://api.sapling.ai/api/v1/thesaurus \
-H "Content-Type: application/json" \
-d '{
"key":"<api-key>",
"query":"pet",
}'

Sample Response

{
"neighbors": [
[
0.8128582835197449,
"dog"
],
[
0.7802609205245972,
"cat"
],
[
0.7524483799934387,
"puppy"
],
[
0.7283433079719543,
"animal"
]
],
"synonyms": [
"darling",
"favorite",
"favourite",
"dearie",
"deary",
"ducky",
"positron_emission_tomography",
"favored",
"best-loved",
"preferred",
"preferent"
]
}

Request Parameters

https://api.sapling.ai/api/v1/thesaurus

HTTP method: POST

key: String
32-character API key

query: String
Term to find similar terms for.

Response Parameters

JSON containing similar terms from a lexical database (WordNet) as well as from a semantic database (terms matched using embedding similarity).

The semantically similar terms are in the neighbors field. Each neighbor also includes a floating point value indicating the similarity from 0 to 1 (with 1 being most similar).

The synonyms from the lexical database are provided in a list under the synonyms field.

Output structure:

{
"neighbors": [
[
0.8440492153167725,
"puppy"
],
[
0.8339642882347107,
"cat"
],
[
0.8266059160232544,
"pup"
],
[
0.8128583431243896,
"pet"
]
],
"synonyms": [
"domestic_dog",
"Canis_familiaris",
"frump",
...
]
}