WNDB(5WN)

🌈 WNDB(5WN) β€” WordNetβ„’ File Formats 🌈

okay bestie, sit down, hydrate, because this is THE page about the actual WordNet database files and it's a lot but we're gonna get through it together πŸ’–


πŸ’– NAME πŸ’–

The database files themselves, the whole squad:

  • index.noun, data.noun, index.verb, data.verb, index.adj, data.adj, index.adv, data.adv β€” the WordNet database files, the main characters ✨
  • noun.exc, verb.exc. adj.exc adv.exc β€” the morphology exception lists πŸ¦‹
  • sentidx.vrb, sents.vrb β€” files used by search code to display sentences illustrating the use of some specific verbs πŸ“

🌸 DESCRIPTION 🌸

So for each syntactic category you need two files to hold the whole WordNet database β€” index.pos and data.pos, where pos is noun, verb, adj and adv. That's the core four, times two. πŸ’… The other auxiliary files are the ones the WordNet library's searching functions use, and you need them to run the various WordNet browsers. No cap.

Every index file is an alphabetized list of all the words found in WordNet in that corresponding part of speech. On each line, right after the word, you get a list of byte offsets (synset_offsets) into the corresponding data file β€” one for each synset containing that word. Words in the index file are lower case only, no matter how they were entered in the lexicographer files. This folds all the different orthographic representations of a word into one single line, which is literally the whole reason database searches can be case insensitive. πŸŽ€ If you want the detailed description of the lexicographer files, go see wninput(5WN).

A data file for a syntactic category contains information corresponding to the synsets that were specified in the lexicographer files, with relational pointers resolved to synset_offsets. Each line corresponds to a synset. πŸ”₯ Pointers are followed and hierarchies traversed by moving from one synset to another via the synset_offsets. It's giving graph traversal, honestly.

The exception list files, pos.exc, are used to help the morphological processor find base forms from irregular inflections. 🧚

The files sentidx.vrb and sents.vrb contain sentences illustrating the use of specific senses of some verbs. These files are used by the searching software in response to a request for verb sentence frames. Generic sentence frames are displayed when an illustrative sentence is not present. The fallback is real πŸ™ˆ

The various database files are in ASCII formats that are easily read by both humans and machines β€” iconic, accessible, bilingual in the human/computer sense πŸ’œ. All fields, unless otherwise noted, are separated by one space character, and all lines are terminated by a newline character. Fields enclosed in italicized square brackets may not be present. (Yes, optional fields, they're the shy ones.)

See wngloss(7WN) for a glossary of WordNet terminology and a discussion of the database's content and logical organization. πŸ‘‘


✨ Index File Format ✨

Every index file kicks off with several lines containing a copyright notice, version number and license agreement. These lines all begin with two spaces and the line number, so they do not interfere with the binary search algorithm that's used to look up entries in the index files. Bestie that's so smart. 🧠✨

All other lines are in the following format. And in the field descriptions below, number always refers to a decimal integer unless otherwise defined. k?

lemma  pos  synset_cnt  p_cnt  [ptr_symbol...]  sense_cnt  tagsense_cnt   synset_offset  [synset_offset...]
  • lemma β€” lower case ASCII text of word or collocation. Collocations are formed by joining individual words with an underscore (_) character.
  • pos β€” Syntactic category: n for noun files, v for verb files, a for adjective files, r for adverb files.
  • All remaining fields are with respect to senses of lemma in pos. πŸ‘€
  • synset_cnt β€” Number of synsets that lemma is in. This is the number of senses of the word in WordNet. See Sense Numbers below for a discussion of how sense numbers are assigned and the order of synset_offsets in the index files.
  • p_cnt β€” Number of different pointers that lemma has in all synsets containing it.
  • ptr_symbol β€” A space separated list of p_cnt different types of pointers that lemma has in all synsets containing it. See wninput(5WN) for a list of pointer_symbols. If all senses of lemma have no pointers, this field is omitted and p_cnt is 0. πŸ«₯
  • sense_cnt β€” Same as sense_cnt above. This is redundant, but the field was preserved for compatibility reasons. (Legacy code said "keep me" and everyone said okay πŸ’€)
  • tagsense_cnt β€” Number of senses of lemma that are ranked according to their frequency of occurrence in semantic concordance texts. πŸ“Š
  • synset_offset β€” Byte offset in data.pos file of a synset containing lemma. Each synset_offset in the list corresponds to a different sense of lemma in WordNet. synset_offset is an 8 digit, zero-filled decimal integer that can be used with fseek(3) to read a synset from the data file. When passed to read_synset(3WN) along with the syntactic category, a data structure containing the parsed synset is returned. πŸŽ€βœ¨

πŸ¦‹ Data File Format πŸ¦‹

Each data file begins with several lines containing a copyright notice, version number and license agreement. These lines all begin with two spaces and the line number. All other lines are in the following format. Integer fields are of fixed length, and are zero-filled. Very demure, very padded πŸ™ˆ

synset_offset  lex_filenum  ss_type  w_cnt  word  lex_id  [word  lex_id...]  p_cnt  [ptr...]  [frames...]  |  gloss
  • synset_offset β€” Current byte offset in the file represented as an 8 digit decimal integer.
  • lex_filenum β€” Two digit decimal integer corresponding to the lexicographer file name containing the synset. See lexnames(5WN) for the list of filenames and their corresponding numbers. πŸ“
  • ss_type β€” One character code indicating the synset type:
    • n β€” NOUN
    • v β€” VERB
    • a β€” ADJECTIVE
    • s β€” ADJECTIVE SATELLITE
    • r β€” ADVERB
  • w_cnt β€” Two digit hexadecimal integer indicating the number of words in the synset.
  • word β€” ASCII form of a word as entered in the synset by the lexicographer, with spaces replaced by underscore characters (_). The text of the word is case sensitive, in contrast to its form in the corresponding index.pos file, that contains only lower-case forms. In data.adj, a word is followed by a syntactic marker if one was specified in the lexicographer file. A syntactic marker is appended, in parentheses, onto word without any intervening spaces. See wninput(5WN) for a list of the syntactic markers for adjectives. πŸ‘‘
  • lex_id β€” One digit hexadecimal integer that, when appended onto lemma, uniquely identifies a sense within a lexicographer file. lex_id numbers usually start with 0, and are incremented as additional senses of the word are added to the same file, although there is no requirement that the numbers be consecutive or begin with 0. Note that a value of 0 is the default, and therefore is not present in lexicographer files. 🫢
  • p_cnt β€” Three digit decimal integer indicating the number of pointers from this synset to other synsets. If p_cnt is 000 the synset has no pointers. 🚫
  • ptr β€” A pointer from this synset to another. ptr is of the form:
pointer_symbol  synset_offset  pos  source/target

where synset_offset is the byte offset of the target synset in the data file corresponding to pos.

The source/target field distinguishes lexical and semantic pointers. It is a four byte field, containing two two-digit hexadecimal integers. The first two digits indicate the word number in the current (source) synset, the last two digits indicate the word number in the target synset. A value of 0000 means that pointer_symbol represents a semantic relation between the current (source) synset and the target synset indicated by synset_offset.

A lexical relation between two words in different synsets is represented by non-zero values in the source and target word numbers. The first and last two bytes of this field indicate the word numbers in the source and target synsets, respectively, between which the relation holds. Word numbers are assigned to the word fields in a synset, from left to right, beginning with 1. πŸ”’

See wninput(5WN) for a list of pointer_symbols, and semantic and lexical pointer classifications.

  • frames β€” In data.verb only, a list of numbers corresponding to the generic verb sentence frames for words in the synset. frames is of the form:
f_cnt   +   f_num  w_num  [ +   f_num  w_num...]

where f_cnt is a two digit decimal integer indicating the number of generic frames listed, f_num is a two digit decimal integer frame number, and w_num is a two digit hexadecimal integer indicating the word in the synset that the frame applies to. As with pointers, if this number is 00, f_num applies to all words in the synset. If non-zero, it is applicable only to the word indicated. Word numbers are assigned as described for pointers. Each f_num w_num pair is preceded by a +. See wninput(5WN) for the text of the generic sentence frames. πŸŽ€

  • gloss β€” Each synset contains a gloss. A gloss is represented as a vertical bar (|), followed by a text string that continues until the end of the line. The gloss may contain a definition, one or more example sentences, or both. πŸ’œ

🌟 Sense Numbers 🌟

Senses in WordNet are generally ordered from most to least frequently used, with the most common sense numbered 1. Frequency of use is determined by the number of times a sense is tagged in the various semantic concordance texts. Senses that are not semantically tagged follow the ordered senses. The tagsense_cnt field for each entry in the index.pos files indicates how many of the senses in the list have been tagged. πŸ“ˆβœ¨

(yes bestie, the vibe check on "which sense is THE sense" is literally just tag counts. iconic.)

okay so the cntlist(5WN) file that comes bundled with the database? it's literally a running tally of how many times each sense got tagged in the semantic concordances πŸ’… and grind(1WN) is the one who eats that data to sort out the sense order for every single word. when the index.pos files get generated, the synset_offsets come out in sense number order β€” sense 1 sitting pretty at the top of the list, always. and when two senses have the exact same number of semantic tags? they get unique but consecutive sense numbers, so nobody's fighting over a spot 🫢. then the WordNet OVERVIEW search rolls up and shows you all the senses of the word you asked about, in every syntactic category, and tells you which of those senses are actually represented in the semantically tagged texts. iconic.

🌸 Exception List File Format 🌸

Exception lists are alphabetized lists of inflected forms of words plus their base forms, bestie. the first field on each line is an inflected form, and after that comes a space separated list of one or more base forms of that word. and yes β€” there's one exception list file for each syntactic category πŸ“‚.

real talk: the noun and verb exception lists were generated automatically from a machine-readable dictionary, so they contain a lot of words that aren't in WordNet at all. and for tons of those inflected forms, the base form could've been derived super easily using the standard rules of detachment that are programmed into Morphy (peep morph(7WN) for that). these anomalies are just... allowed to stay in the exception list files, because honestly? they do no harm. live and let live ✨.

πŸ¦‹ Verb Example Sentences πŸ¦‹

for some verb senses, you can actually display example sentences that show off how that verb sense gets used πŸ‘‘.

each line of the file sentidx.vrb has a sense_key followed by a space and then a comma separated list of example sentence template numbers, in decimal. and the file sents.vrb lists all of the example sentence templates β€” every line starts with the template number followed by a space, and the rest of the line is the text of a template example sentence, with %s chillin' there as a placeholder for the verb πŸŽ€.

both files are sorted alphabetically so that the sense_key and the template sentence number can be used as indices, via binsrch(3WN), into the appropriate file. efficient queen.

so when a request for FRAMES comes in, the WordNet search code goes looking for the sense in sentidx.vrb. found it? the sentence template(s) listed get retrieved from sents.vrb, and that %s gets swapped out for the verb πŸ”₯. not found? then the applicable generic sentence frame(s) listed in frames get displayed instead. either way you're getting something, no dead ends here πŸ’–.


πŸ’œ NOTES πŸ’œ

the info in the data.pos and index.pos files represents all of the word senses and synsets in the WordNet database, periodt. the word, lex_id, and lex_filenum fields together uniquely identify each word sense in WordNet β€” and they can be encoded into a sense_key, exactly as described in senseidx(5WN) 🫢.

every synset in the database can be uniquely identified by combining the synset_offset for that synset with a code for the syntactic category β€” and yeah, you need that category code, because it's totally possible for synsets in different data.pos files to have the same synset_offset πŸ’€.

the WordNet system provides both command line and window-based browser interfaces to the database, and both of them utilize a common library of search and morphology code 🧚. the source code for the library and the interfaces is included in the WordNet package. see wnintro(3WN) for an overview of the WordNet source code ⭐.


🌈 ENVIRONMENT VARIABLES (UNIX) 🌈

  • WNHOME β€” base directory for WordNet. the default is /usr/local/WordNet-3.0.
  • WNSEARCHDIR β€” the directory where the WordNet database has been installed. the default is WNHOME/dict.

πŸŽ€ REGISTRY (WINDOWS) πŸŽ€

  • HKEY_LOCAL_MACHINE\SOFTWARE\WordNet\3.0\WNHome β€” base directory for WordNet. the default is C:\Program Files\WordNet\3.0.

πŸ’– FILES πŸ’–

  • index.pos β€” database index files
  • data.pos β€” database data files
  • *.vrb β€” files of sentences illustrating the use of verbs
  • pos.exc β€” morphology exception lists

✨ SEE ALSO ✨

grind(1WN), wn(1WN), wnb(1WN), wnintro(3WN), binsrch(3WN), wnintro(5WN), cntlist(5WN), lexnames(5WN), senseidx(5WN), wninput(5WN), morphy(7WN), wngloss(7WN), wngroups(7WN), wnstats(7WN).


and that's a wrap bestie 🫢 this whole thing is WordNet 3.0, dated Dec 2006, and you're reading the WNDB(5WN) page β€” go forth and slay πŸ’…πŸŒΈ