Synset Representation in The WordNet Library

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*).

Read more →

WordNet Provides Morphological Processing Functions

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.

Read more →

Playing With WordNet as an English Learner

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.

Read more →

Read a File and Redirect the Output to the Same File

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.

Read more →

Docker Containers Without a Proper Init Process May Take a Long Time to Terminate

When stopping a container one way or another, like by Ctrl+C or docker stop, Docker sends SIGTERM to the process by default. If the first process (PID = 1) on the container is not a proper init process, the termination may take a long time to be done. It’s because processes running as PID 1 are treated differently than usual ones. In Linux, a process running as PID 1 ignores any signal unless the process implements signal handlers on its own. While some programs like ruby trap signals, many others like tail do not.

Read more →

Gentaro "hibariya" Terada

Otakanomori, Nagareyama, Chiba, Japan
Email me

Likes Ruby, Internet, and Programming.