MORPH(3)

πŸ“¦
version 3.0 Β· 2 versions
, in fedora 43, fedora 44, opensuse-leap 16.0

πŸ’– MORPH(3) β€” WordNetβ„’ Library Functions πŸ’–

okay bestie, so this is the manual page for the WordNet morphological processor functions, part of the WordNetβ„’ Library Functions. It's MORPH(3), she's iconic, she's literally the group chat of C functions that figure out what a word's base form is. Let's go πŸ¦‹


✨ NAME ✨

morphinit, re_morphinit, morphstr, morphword β€” the WordNet morphological processor functions. Yes queen, four of them, and they all live in the same little friend group πŸ’…


🌸 SYNOPSIS 🌸

#include "wn.h"

int morphinit(void);

int re_morphinit(void);

char *morphstr(char *origstr, int pos);

char *morphword(char *word, int pos);

πŸŽ€ DESCRIPTION πŸŽ€

The WordNet morphological processor, Morphy, is accessed through these functions, and honestly? She's doing a lot. Let's break it down:

  • morphinit() β€” this one is the door-opener. It opens the exception list files. Returns 0 if it slays (successful), -1 otherwise. Heads up bestie: the exception list files must be opened before morphstr() or morphword() get called, or it's giving chaos 😭
  • re_morphinit() β€” closes the exception list files and then reopens them. It's used exclusively for WordNet development, so unless you're doing dev work, this one's not your moment. Return codes are exactly as described above (0 = good, -1 = not good).
  • morphstr() β€” the main character, the basic user interface to Morphy. It tries to find the base form (lemma) of the word or collocation origstr in the specified pos.
    • The first call (with origstr specified) returns a pointer to the first base form found.
    • Subsequent calls asking for base forms of the same string must be made with the first argument as NULL. Periodt.
    • When there are no more base forms for origstr to find, NULL is returned. That's your cue that she's done πŸ’€
    • > 🚨 IMPORTANT: morphstr() returns a pointer to a static character buffer. A subsequent call to morphstr() with a new string (instead of NULL) will overwrite the string pointed to by a previous call. So copy the returned string into a local buffer, or use the C library function strdup to duplicate the returned string into a malloc'd buffer. Do not skip this, I am begging πŸ™ˆ
  • morphword() β€” tries to find the base form of word in the specified pos. This function is called by morphstr() for each individual word in a collocation. Same vibe warning as above, fr fr: morphword() returns a pointer to a static character buffer, and a subsequent call to morphword() will overwrite the string pointed to by a previous call. Copy the returned string into a local buffer, or use the C library function strdup to duplicate the returned string into a malloc'd buffer. ✨

πŸ’œ NOTES πŸ’œ

  • morphinit() is called by wninit() and is not intended to be called directly by an application. Applications wishing to use WordNet and/or the morphological functions must call wninit() at the start of the program. See wnutil(3) for more information 🫢
  • origstr may be either a word or a collocation formed by joining individual words with underscore characters (_). That's the glue, bestie.
  • Usually only morphstr() is called from applications, because it works on both words and collocations. She does it all πŸ‘‘
  • pos must be one of the following:
       1    NOUN
       2    VERB
       3    ADJECTIVE
       4    ADVERB
       5    ADJECTIVE_SATELLITE
  • If ADJECTIVE_SATELLITE is passed, it is treated by morphstr() as ADJECTIVE. Same energy, different label 🌈

πŸ”₯ SEE ALSO πŸ”₯

wnintro(3), wnsearch(3), wndb(5), morphy(7).


⚠️ WARNINGS ⚠️

πŸ’€ Passing an invalid part of speech will result in a core dump. Not a vibe. Not the moment. Check your pos.
πŸ“‚ The WordNet database files must be open to use morphstr() or morphword().

πŸ› BUGS πŸ›

Morphy will allow non-words to be converted to words, if they follow one of the rules described above. For example, it will happily convert plantes to plants. She's confident like that, and honestly? We love the self-belief, but be aware 😭


WordNet 3.0 Β· Dec 2006 β€” that's the version and date from the original footer, bestie. Made with love, static buffers, and a whole lot of Morphy magic. Stay safe, copy your strings, and call wninit() first πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from