I am creating a tiny tool to explore relationships between two words utilizing WordNet: Astrolabe. It is intended to help ESL learners like me to grasp a clearer picture of a particular sense by recognizing the relationships between two words that have something in common.
Motivation I have been trying to extend my vocabulary with Anki for years, little by little. It is an awesome tool to learn new words. I have learned about 6,000 words with it. Thanks to that, now it is much easier to read books and discuss diverse topics in English.
In the WordNet library, a synset is represented by a struct called Synset. There are 26 members in this struct. While playing with tracing the WordNet graph, I had a chance to use half of them. Let me introduce them.
Basic Information About The Synset Itself char* defn is a short description of the synset (a.k.a. gloss). It often includes a couple of short example sentences, too. int* pos is the part of speech of the synset. It is a character like “n” as in “noun” and “v” as in “verb”. In many cases, a pos is represented by an integer, and here’s not the case for some reason. You can get the integer representation of the corresponding character with the utility function int getpos(char*).
WordNet library has handy functions to deal with irregular inflections like morphstr(). It tries to find the base form of the given word and the pos (part of speech) in the database.
When it comes to looking up a word with WordNet, the word is often unfamiliar for the person. You can guess whether the word is singular or plural form, present or past tense from the context of the sentence. However, you cannot be 100% sure about the base form because there is a possibility that the word morphs in an unexpected way. If you are not sure about the base form of a given word, morphstr() would help.
TL; DR WordNet helps English learners with getting a clearer grasp of relationships between a couple of words. Its API lets the users explore the whole network of English words in their own way along with their purpose.
WordNet is a huge lexical database of English. Every sense of words is represented as a “synset” (a set of synonyms) in the database. Every synset has its short definition with a couple of example sentences and pointers to related words.
To write outputs to a file in a shell, we can use redirection. However, when we read a file and modify the content and redirect to the same original file, we’ll get just an empty file. What’s going on here?
$ cat file bravo delta charlie alpha charlie $ cat file | sort | uniq > file $ cat file # empty file $ Of course, if you redirect to a different file and rename it to the original name, it works as expected. This behavior is a little annoying when we want to modify a file like sorting and removing duplicates and do it without creating any temporary file. The reason redirecting output to the source file ends up an empty file is the redirection truncates the destination file earlier than the command actually starts processing.