WNSEARCH(3WN)
πΈ NAME πΈ
okay so bestie, welcome to WNSEARCH(3WN) β aka WordNetβ’ Library Functions π. This is the whole friend group of C functions you use to search the WordNet database. The squad is:
findtheinfofindtheinfo_dsis_definedin_wnindex_lookupparse_indexgetindexread_synsetparse_synsetfree_synsfree_synsetfree_indextraceptrs_dsdo_trace
and their entire thing is functions for searching the WordNet database. periodt. π
β¨ SYNOPSIS β¨
#include "wn.h"
char *findtheinfo(char *searchstr, int pos, int ptr_type, int
sense_num);
SynsetPtr findtheinfo_ds(char *searchstr, int pos, int ptr_type, int
sense_num );
unsigned int is_defined(char *searchstr, int pos);
unsigned int in_wn(char *searchstr, int pos);
IndexPtr index_lookup(char *searchstr, int pos);
IndexPtr parse_index(long offset, int dabase, char *line);
IndexPtr getindex(char *searchstr, int pos);
SynsetPtr read_synset(int pos, long synset_offset, char *searchstr);
SynsetPtr parse_synset(FILE *fp, int pos, char *searchstr);
void free_syns(SynsetPtr synptr);
void free_synset(SynsetPtr synptr);
void free_index(IndexPtr idx);
SynsetPtr traceptrs_ds(SynsetPtr synptr, int ptr_type, int pos, int
depth);
char *do_trace(SynsetPtr synptr, int ptr_type, int pos, int depth);
π DESCRIPTION π
These functions are used for searching the WordNet database, fr fr. They generally fall into several categories: functions for reading and parsing index file entries; functions for reading and parsing synsets in data files; functions for tracing pointers and hierarchies; functions for freeing space occupied by data structures allocated with malloc(3).
In the following function descriptions, pos is one of the following:
1 NOUN
2 VERB
3 ADJECTIVE
4 ADVERB
findtheinfo() is the primary search algorithm for use with database interface applications. Search results are automatically formatted, and a pointer to the text buffer is returned. All searches listed in WNHOME/include/wn.h can be done by findtheinfo(). findtheinfo_ds() can be used to perform most of the searches, with results returned in a linked list data structure. This is for use with applications that need to analyze the search results rather than just display them. main character energy, honestly. π
Both functions are passed the same arguments: searchstr is the word or collocation to search for; pos indicates the syntactic category to search in; ptr_type is one of the valid search types for searchstr in pos. (Available searches can be obtained by calling is_defined() described below.) sense_num should be ALLSENSES if the search is to be done on all senses of searchstr in pos, or a positive integer indicating which sense to search.
findtheinfo_ds() returns a linked list data structures representing synsets. Senses are linked through the nextss field of a Synset data structure. For each sense, synsets that match the search specified with ptr_type are linked through the ptrlist field. See Synset Navigation, below, for detailed information on the linked lists returned.
is_defined() sets a bit for each search type that is valid for searchstr in pos, and returns the resulting unsigned integer. Each bit number corresponds to a pointer type constant defined in WNHOME/include/wn.h. For example, if bit 2 is set, the HYPERPTR search is valid for searchstr. There are 29 possible searches. no cap. π₯
in_wn() is used to find the syntactic categories in the WordNet database that contain one or more senses of searchstr. If pos is ALL_POS, all syntactic categories are checked. Otherwise, only the part of speech passed is checked. An unsigned integer is returned with a bit set corresponding to each syntactic category containing searchstr. The bit number matches the number for the part of speech. 0 is returned if searchstr is not present in pos.
index_lookup() finds searchstr in the index file for pos and returns a pointer to the parsed entry in an Index data structure. searchstr must exactly match the form of the word (lower case only, hyphens and underscores in the same places) in the index file. NULL is returned if a match is not found. it's giving exact match or nothing. π
parse_index() parses an entry from an index file and returns a pointer to the parsed entry in an Index data structure. Passed the byte offset and syntactic category, it reads the index entry at the desired location in the corresponding file. If passed line, line contains an index file entry and the database index file is not consulted. However, offset and dbase should still be passed so the information can be stored in the Index structure.
getindex() is a "smart" search for searchstr in the index file corresponding to pos. It applies to searchstr an algorithm that replaces underscores with hyphens, hyphens with underscores, removes hyphens and underscores, and removes periods in an attempt to find a form of the string that is an exact match for an entry in the index file corresponding to pos. index_lookup() is called on each transformed string until a match is found or all the different strings have been tried. It returns a pointer to the parsed Index data structure for searchstr, or NULL if a match is not found. slay, bestie. β¨
read_synset() is used to read a synset from a byte offset in a data file. It performs an fseek(3) to synset_offset in the data file corresponding to pos, and calls parse_synset() to read and parse the synset. A pointer to the Synset data structure containing the parsed synset is returned.
parse_synset() reads the synset at the current offset in the file indicated by fp. pos is the syntactic category, and searchstr, if not NULL, indicates the word in the synset that the caller is interested in. An attempt is made to match searchstr to one of the words in the synset. If an exact match is found, the whichword field in the Synset structure is set to that word's number in the synset (beginning to count from 1). obsessed with this level of detail. π
free_syns() is used to free a linked list of Synset structures allocated by findtheinfo_ds(). synptr is a pointer to the list to free.
free_synset() frees the Synset structure pointed to by synptr.
free_index() frees the Index structure pointed to by idx.
traceptrs_ds() is a recursive search algorithm that traces pointers matching ptr_type starting with the synset pointed to by synptr. Setting depth to 1 when traceptrs_ds() is called indicates a recursive search; 0 indicates a non-recursive call. synptr points to the data structure representing the synset to search for a pointer of type ptr_type. When a pointer type match is found, the synset pointed to is read and linked onto the nextss chain. Levels of the tree generated by a recursive search are linked via the ptrlist field structure until NULL is found, indicating the top (or bottom) of the tree. This function is usually called from findtheinfo_ds() for each sense of the word. See Synset Navigation, below, for detailed information on the linked lists returned.
do_trace() performs the search indicated by ptr_type on synset synptr in syntactic category pos. depth is defined as above. do_trace() returns the search results formatted in a text buffer. ate. π
π¦ Synset Navigation π¦
Since the Synset structure is used to represent the synsets for both word senses and pointers, the ptrlist and nextss fields have different meanings depending on whether the structure is a word sense or pointer. This can make navigation through the lists returned by findtheinfo_ds() confusing. iykyk. π
Navigation through the returned list involves the following:
- Following the
nextsschain from the synset returned moves through the various senses ofsearchstr.NULLindicates that end of the chain of senses. - Following the
ptrlistchain from aSynsetstructure representing a sense traces the hierarchy of the search results for that sense. Subsequent links in theptrlistchain indicate the next level (up or down, depending on the search) in the hierarchy.NULLindicates the end of the chain of search result synsets. - If a synset pointed to by
ptrlisthas a value in thenextssfield, it represents another pointer of the same type at that level in the hierarchy. For example, some noun synsets have two hypernyms. Following thisnextsspointer, and then theptrlistchain from theSynsetstructure pointed to, traces another, parallel, hierarchy, until the end is indicated byNULLon thatptrlistchain. So, a synset representing a pointer (versus a sense ofsearchstr) having a non-NULLvalue innextsshas another chain of search results linked through theptrlistchain of the synset pointed to bynextss. - If
searchstrcontains more than one base form in WordNet (as in the nounaxes, which has base formsaxeandaxis), synsets representing the search results for each base form are linked through thenextformpointer of theSynsetstructure.
π WordNet Searches π
There is no extensive description of what each search type is or the results returned. Using the WordNet interface, examining the source code, and reading wndb(5WN) are the best ways to see what types of searches are available and the data returned for each.
Listed below are the valid searches that can be passed as ptr_type to findtheinfo(). Passing a negative value (when applicable) causes a recursive, hierarchical search by setting depth to 1 when traceptrs() is called.
okay so THIS is the part where it gets real, bestie β here's the full rundown of every ptr_type you can throw at these functions, with its numeric value, the symbol it maps to in WordNet's search syntax, and what it actually searches. Keep this one pinned π
ββββββββββββββββββββ¬ββββββββ¬ββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β ptr_type β Value β Pointer β Search β
β β β Symbol β β
ββββββββββββββββββββΌββββββββΌββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββ€
β ANTPTR β 1 β ! β Antonyms β
β HYPERPTR β 2 β @ β Hypernyms β
β HYPOPTR β 3 β βΌ β Hyponyms β
β ENTAILPTR β 4 β * β Entailment β
β SIMPTR β 5 β & β Similar β
β ISMEMBERPTR β 6 β #m β Member meronym β
β ISSTUFFPTR β 7 β #s β Substance meronym β
β ISPARTPTR β 8 β #p β Part meronym β
β HASMEMBERPTR β 9 β %m β Member holonym β
β HASSTUFFPTR β 10 β %s β Substance holonym β
β HASPARTPTR β 11 β %p β Part holonym β
β MERONYM β 12 β % β All meronyms β
β HOLONYM β 13 β # β All holonyms β
β CAUSETO β 14 β > β Cause β
β PPLPTR β 15 β < β Participle of verb β
β SEEALSOPTR β 16 β ^ β Also see β
β PERTPTR β 17 β \ β Pertains to noun or derived from adjective β
β ATTRIBUTE β 18 β \= β Attribute β
β VERBGROUP β 19 β $ β Verb group β
β DERIVATION β 20 β + β Derivationally related form β
β CLASSIFICATION β 21 β ; β Domain of synset β
β CLASS β 22 β - β Member of this domain β
β SYNS β 23 β n/a β Find synonyms β
β FREQ β 24 β n/a β Polysemy β
β FRAMES β 25 β n/a β Verb example sentences and generic frames β
β COORDS β 26 β n/a β Noun coordinates β
β RELATIVES β 27 β n/a β Group related senses β
β HMERONYM β 28 β n/a β Hierarchical meronym search β
β HHOLONYM β 29 β n/a β Hierarchical holonym search β
β WNGREP β 30 β n/a β Find keywords by substring β
β OVERVIEW β 31 β n/a β Show all synsets for word β
β CLASSIF_CATEGORY β 32 β ;c β Show domain topic β
β CLASSIF_USAGE β 33 β ;u β Show domain usage β
β CLASSIF_REGIONAL β 34 β ;r β Show domain region β
β CLASS_CATEGORY β 35 β -c β Show domain terms for topic β
β CLASS_USAGE β 36 β -u β Show domain terms for usage β
β CLASS_REGIONAL β 37 β -r β Show domain terms for region β
β INSTANCE β 38 β @i β Instance of β
β INSTANCES β 39 β βΌi β Show instances β
ββββββββββββββββββββ΄ββββββββ΄ββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββ
and now the sad part π β findtheinfo_ds() is not invited to the party for these searches, like at all:
SEEALSOPTRPERTPTRVERBGROUPFREQFRAMESRELATIVESWNGREPOVERVIEW
π«Ά NOTES π«Ά
rule number one, bestie, no skipping it: any application that uses WordNet and/or the morphological functions must call wninit() at the start of the program. See wnutil(3WN) for more info. (fr fr, call it first.)
In all function calls, searchstr may be either a word or a collocation formed by joining individual words with underscore characters (_). so like, one word or a bunch glued together with underscores, both valid π
The SearchResults structure defines fields in the wnresults global variable that are set by the various search functions. This is a way to get additional information β such as the number of senses the word has β from the search functions. The searchds field is set by findtheinfo_ds(). basically free extra intel from the same call, we love an efficient queen β¨
And the pos passed to traceptrs_ds()? It is not used. That's it. That's the whole note. traceptrs_ds() just... ignores it. π
π SEE ALSO π
wn(1WN)wnb(1WN)wnintro(3WN)binsrch(3WN)malloc(3)morph(3WN)wnutil(3WN)wnintro(5WN)
the whole friend group, go say hi π¦
π¨ WARNINGS π¨
read this section. I'm so serious. no cap.
parse_synset()must find an exact match between the searchstr passed and a word in the synset to set whichword. No attempt is made to translate hyphens and underscores, as is done ingetindex(). (exact match or nothing, bestie β don't come at it with your cute little hyphens)- The WordNet database and exception list files must be opened with
wninitprior to using any of the searching functions. prior. before. first. in that order. π - A large search may cause
findtheinfo()to run out of buffer space. The maximum buffer size is determined by computer platform. If the buffer size is exceeded the following message is printed in the output buffer:"Search too large. Narrow search and try again...". so if you see that string, that's not a vibe check fail on your part, that's just the buffer saying "too much, bestie" π - Passing an invalid pos will probably result in a core dump. like, genuinely. segfault city. do NOT do this. it's giving chaos. π
and that's the whole page, you made it, I'm so proud of you π₯Ήπ
This is the WordNet 3.0 manual, dated Dec 2006, and it lives under the name WNSEARCH(3WN) β slay, go search some synsets, you've got this π
β¨
π¦ where this page comes from
- debian bookworm: wordnet-dev 1:3.0-37 Β· WordNet3.0
- debian trixie: wordnet-dev 1:3.0-39 Β· WordNet3.0
- ubuntu jammy: wordnet-dev 1:3.0-37 Β· WordNet3.0
- ubuntu noble: wordnet-dev 1:3.0-37 Β· WordNet3.0
- ubuntu questing: wordnet-dev 1:3.0-40
- ubuntu resolute: wordnet-dev 1:3.0-41 Β· WordNet3.0
- ubuntu stonking: wordnet-dev 1:3.0-41 Β· WordNet3.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms