---
name: "wnutil"
section: "3"
platform: "linux"
package: "wordnet-dev"
version: "1.7-6"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/wnutil"
---

# wnutil(3)

## NAME

wninit, re\_wninit, cntwords, strtolower, ToLowerCase, strsubst, getptrtype, getpos, getsstype, StrToPos, GetSynsetForSense, GetDataOffset, GetPolyCount, WNSnsToStr, GetValidIndexPointer, GetWNSense, GetSenseIndex, default\_display\_message

## SYNOPSIS

**#include "wn.h"**

**int wninit(void);**

**int re\_wninit(void);**

**int cntwords(char \*str, char separator);**

**char \*strtolower(char \*str);**

**char \*ToLowerCase(char \*str);**

**char \*strsubst(char \*str, char from, char to);**

**int getptrtype(char \*ptr\_symbol);**

**int getpos(char \*ss\_type);**

**int getsstype(char \*ss\_type);**

**int StrToPos(char pos);**

**SynsetPtr GetSynsetForSense(char \*sense\_key);**

**long GetDataOffset(char \*sense\_key);**

**int GetPolyCount(char \*sense\_key);**

**char \*WNSnsToStr(IndexPtr idx, int sense\_num);**

**IndexPtr GetValidIndexPointer(char \*str, int pos);**

**int GetWNSense(char \*lemma, \*lex\_sense);**

**SnsIndexPtr GetSenseIndex(char \*sense\_key);**

**int GetTagcnt(IndexPtr idx, int sense);**

**int default\_display\_message(char \*msg);**

## DESCRIPTION

The WordNet library contains many utility functions used by the interface code, other library functions, and various applications and tools.  Only those of importance to the WordNet search code, or which are generally useful are described here.

**wninit()** opens the files necessary for using WordNet with the WordNet library functions.  The database files are opened, and  **morphinit()** is called to open the exception list files.  Returns **0** if successful, **-1** otherwise.  The database and exception list files must be open before the WordNet search and morphology functions are used.  If the database is successfully opened, the global variable **OpenDB** is set to **1**.  Note that it is possible for the database files to be opened (**OpenDB == 1**), but not the exception list files.

**re\_wninit()** is used to close the database files and reopen them, and is used exclusively for WordNet development. **re\_morphinit()** is called to close and reopen the exception list files.  Return codes are as described above.

**cntwords()** counts the number of underscore or space separated words in *str*. A hyphen is passed in *separator* if is is to be considered a word delimiter.  Otherwise *separator* can be any other character, or an underscore if another character is not desired.

**strtolower()** converts *str* to lower case and removes a trailing adjective marker, if present.  *str* is actually modified by this function, and a pointer to the modified string is returned.

**ToLowerCase()** converts *str* to lower case as above, without removing an adjective marker.

**strsubst()** replaces all occurrences of *from* with *to* in *str* and returns resulting string.

**getptrtype()** returns the integer *ptr\_type* corresponding to the pointer character passed in *ptr\_symbol*.  See **wnsearch**(3WN) for a table of pointer symbols and types.

**getpos()** returns the integer constant corresponding to the synset type passed. *ss\_type* may be one of the following: **n, v, a, r, s**.  If **s** is passed, **ADJ** is returned.  Exits with **-1** if *ss\_type* is invalid.

**getsstype()** works like **getpos()**, but returns **SATELLITE** if *ss\_type* is **s**.

**StrToPos()** returns the integer constant corresponding to the syntactic category passed in *pos*.  *string* must be one of the following: **noun, verb, adj, adv**.  **-1** is returned if *pos* is invalid.

**GetSynsetForSense()** returns the synset that contains the word sense *sense\_key* and **NULL** in case of error.

**GetDataOffset()** returns the synset offset for synset that contains the word sense *sense\_key*, and **0** if *sense\_key* is not in sense index file.

**GetPolyCount()** returns the polysemy count (number of senses in WordNet) for *lemma* encoded in *sense\_key* and **0** if word is not found.

**WNSnsToStr()** returns sense key encoding for *sense\_num* entry in *idx*.

**GetValidIndexPointer()** returns the Index structure for *word* in *pos*.  Calls **morphstr**(3WN) to find a valid base form if *word* is inflected.

**GetWNSense()** returns the WordNet sense number for the sense key encoding represented by *lemma* and *lex\_sense*.

**GetSenseIndex()** returns parsed sense index entry for *sense\_key* and  **NULL** if *sense\_key* is not in sense index.

**GetTagcnt()** returns the number of times the sense passed has been tagged in the various semantic concordances.

**default\_display\_message()** simply returns **-1**.  This is the default value for the global variable **display\_message**, that points to a function to call to display an error message.  In general, applications (including the WordNet interfaces) define an application specific function and set **display\_message** to point to it.

## NOTES

**WNHOME/include/wnconsts.h** lists all the pointer and search types and their corresponding constant values.  There is no description of what each search type is or the results returned. Using the WordNet interface is the best way to see what types of searches are available, and the data returned for each.

## SEE ALSO

**wnsearch**(3WN), **morph**(3WN), **wnintro**(5WN), **wnintro**(7WN).

## WARNINGS

Error checking on passed arguments is not rigorous.  Passing  **NULL** pointers or invalid values will often cause an application to die.
