-
Notifications
You must be signed in to change notification settings - Fork 0
Wordnet API structure
This wiki depicts the structure of API that exposes various wordnet methods and functions, at the same time provides an abstraction, facilitating the process of looking up various words in the English language and their related words like synonyms, antonyms, entailments, etc.
/v1/wordnet/group_by_relation
parameters:
-
word is the specified word. Wordnet supports common word usages like 'use up', 'give in', etc. Hence such usages, involving spaces should be transformed into a single string, with each space replace by an underscore. For example, the usage 'use up' should instead be looked up by specifying the value of the parameter word as 'use_up'.
-
relations_to_look_for specifies the relations which are to be used for looking up the related words. Multiple relations are specified by using the underscore character as the concatenating character. For example, to look for all of the synonyms and antonyms of a particular word, we need to specify the value of relations_to_look_for as 'synonyms_antonyms'. If we want to find all of the related words, we specify the value of relations_to_look_for as 'all'. The various relations available as of now are: 'synonym', 'antonym', 'entailment'(this relation gives us a list of words(verbs) which are entailments of the specified word), 'dform'(this relation gives us the derivations of the specified word obtained through lexical modifications), 'hypernym'(this relation gives us words with broader meanings than the specified word), 'hyponym'(this relation gives us words with coarser meanings), 'pmeronym', 'pholonym', 'smeronym' and 'sholonym'.
-
group_by is used to specify the grouping clause. The two options available as of now are, a) group_by_definition which groups the related words by the definitions, and b) group_by_relation which groups the related words by the relations used for looking up the words.
- The endpoint,
v1/wordnet/dive/synonym_dform/group_by_definition/
gives us the following output
{
"a cheap disreputable nightclub or dance hall": {
"synonym": [
"honkytonk"
]
},
"drop steeply": {
"synonym": [
"plunge",
"plunk"
]
},
"someone who works underwater": {
"dform": [
"diver"
]
},
"a steep nose-down descent by an aircraft": {
"synonym": [
"nose_dive",
"nosedive"
]
},
"a distinguished female operatic singer; a female operatic star": {
"synonym": [
"prima_donna",
"diva"
]
},
"someone who dives (into water)": {
"dform": [
"diver"
]
},
"a headlong plunge into water": {
"dform": [
"diving"
],
"synonym": [
"diving"
]
}
}
- The endpoint,
v1/wordnet/dive/synonym_antonym/group_by_relation/
gives us the following output
{
"synonym": {
"a distinguished female operatic singer; a female operatic star": [
"prima_donna",
"diva"
],
"drop steeply": [
"plunge",
"plunk"
],
"a headlong plunge into water": [
"diving"
],
"a steep nose-down descent by an aircraft": [
"nose_dive",
"nosedive"
],
"a cheap disreputable nightclub or dance hall": [
"honkytonk"
]
}
}
The above mentioned endpoint is to be used with the host that is serving the API. Currently one such instance is served by nginx server running on an Ubuntu machine at 192.168.2.35. Hence the url of the two examples would be
http://45.55.220.39:5001/v1/wordnet/dive/synonym_antonym/group_by_relation/
and
http://45.55.220.39:5001/v1/wordnet/dive/synonym_dform/group_by_definition/
In general, the url should look something like
http://45.55.220.39:5001/v1/wordnet/_**word**_/_**relations_to_look_for**_/_**group_by**_
/v1/wordnet/start_word/end_word/relations_to_use/find_similarity
-
start_word is the first word.
-
end_word is the second word. The relations which are to be looked for are non-directional relations.
-
relations_to_use specifies the relations which are to be used for finding the relation of the second word with respect to the first word. Multiple relation types are specified by using the underscore character as the concatenating character. For example, to look for relations between the two words using only synonyms and antonyms, we need to specify the value of relations_to_use as 'synonym_antonym'. If we want to use all of the available relation types for finding the relation between the two words, we specify the value of relations_to_use as 'all'. Any of the relation types specified in the first API can be used for finding the relation between the two words.
/v1/wordnet/chew/tongue/hyponym_hypernym_synonym_dform/find_similarity/
[
{
"start_word": "walk",
"subpaths": [
{
"from": "walk",
"to": "locomote",
"definition": "take a walk; go for a walk; walk for pleasure",
"part_of_speech": "v",
"relation": "hypernym"
},
{
"from": "locomote",
"to": "jump",
"definition": "change location; move, travel, or proceed, also metaphorically",
"part_of_speech": "v",
"relation": "hyponym"
}
],
"end_word": "jump"
},
{
"start_word": "walk",
"subpaths": [
{
"from": "walk",
"to": "locomote",
"definition": "use one's feet to advance; advance by steps",
"part_of_speech": "v",
"relation": "hypernym"
},
{
"from": "locomote",
"to": "jump",
"definition": "change location; move, travel, or proceed, also metaphorically",
"part_of_speech": "v",
"relation": "hyponym"
}
],
"end_word": "jump"
},
{
"start_word": "walk",
"subpaths": [
{
"from": "walk",
"to": "travel",
"definition": "take a walk; go for a walk; walk for pleasure",
"part_of_speech": "v",
"relation": "hypernym"
},
{
"from": "travel",
"to": "jump",
"definition": "change location; move, travel, or proceed, also metaphorically",
"part_of_speech": "v",
"relation": "hyponym"
}
],
"end_word": "jump"
},
{
"start_word": "walk",
"subpaths": [
{
"from": "walk",
"to": "travel",
"definition": "use one's feet to advance; advance by steps",
"part_of_speech": "v",
"relation": "hypernym"
},
{
"from": "travel",
"to": "jump",
"definition": "change location; move, travel, or proceed, also metaphorically",
"part_of_speech": "v",
"relation": "hyponym"
}
],
"end_word": "jump"
},
{
"start_word": "walk",
"subpaths": [
{
"from": "walk",
"to": "travel",
"definition": "the act of walking somewhere",
"part_of_speech": "n",
"relation": "hypernym"
},
{
"from": "travel",
"to": "jump",
"definition": "change location; move, travel, or proceed, also metaphorically",
"part_of_speech": "v",
"relation": "hyponym"
}
],
"end_word": "jump"
},
{
"start_word": "walk",
"subpaths": [
{
"from": "walk",
"to": "travel",
"definition": "the act of traveling by foot",
"part_of_speech": "n",
"relation": "hypernym"
},
{
"from": "travel",
"to": "jump",
"definition": "change location; move, travel, or proceed, also metaphorically",
"part_of_speech": "v",
"relation": "hyponym"
}
],
"end_word": "jump"
},
{
"start_word": "walk",
"subpaths": [
{
"from": "walk",
"to": "pass_over",
"definition": "traverse or cover by walking",
"part_of_speech": "v",
"relation": "hypernym"
},
{
"from": "pass_over",
"to": "jump",
"definition": "bypass",
"part_of_speech": "v",
"relation": "synonym"
}
],
"end_word": "jump"
}
]
This structure warrants some explanation. The algorithm used for looking up the relation between two words is Dijkstra’s shortest path algorithm. The shortest path is defined as the number of nodes lying along the path. Hence here we extract 'all' of the shortest paths between the two words. And Each path as printed here is an element of the list. And each path is again a list of hops(or subpaths). Each subpath is actually a relationship between two nodes. So here a sample subpath involving three nodes, A, B and C, would be a list of two subpaths, one between A and B, and the other between B and C. The relationship could be in any direction, as here directions aren't important. Still each sub-path is specified with the starting word, ending word, the relationship type, definition associated with the relationship and the part of speech in which the starting word is to be used. Additionally, we also specify the starting and the ending words as specified in the API endpoint, for reference purposes.
/v1/wordnet/word/buffer_parameter/find_examples
-
word is the specified word whose examples we are looking for.
-
buffer_parameter is simply a parameter in place to account for a future use of the same endpoint. As of now, this parameter can take up any value but cannot be omitted.
/v1/wordnet/swing/*/find_examples/
{
"change direction with a swinging motion; turn": {
"swing": [
"swing forward"
]
},
"move in a curve or arc, usually with the intent of hitting": {
"swing": [
"swing a bat"
]
},
"a state of steady vigorous action that is characteristic of an activity": {
"swing": [
"it took time to get into the swing of things"
]
}
}
The response for this API is a list of various definitions found for the specified word whose synonyms have examples as obtained from wordnet. Then the response is grouped by the found definitions. Each definition contains the synonyms having examples, with the examples listed out as values with the synonyms themselves as the keys.