Package nltk :: Package wordnet :: Module util
[hide private]
[frames] | no frames]

Module util

source code

Classes [hide private]
  IndexFile
An IndexFile is an implementation class that presents a Sequence and Dictionary interface to a sorted index file.
Functions [hide private]
 
normalizePOS(pos)
Return the standard form of the supplied part of speech.
source code
 
dataFilePathname(filenameroot)
Returns: the full path to the data file.
source code
 
binarySearchFile(file, key, cache={}, cacheDepth=-1)
Searches through a sorted file using the binary search algorithm.
source code
 
getIndex(form, pos='noun')
Search for _form_ in the index file corresponding to _pos_.
source code
Variables [hide private]
  ANTONYM = 'antonym'
  HYPERNYM = 'hypernym'
  HYPONYM = 'hyponym'
  ATTRIBUTE = 'attribute'
  ALSO_SEE = 'also see'
  ENTAILMENT = 'entailment'
  CAUSE = 'cause'
  VERB_GROUP = 'verb group'
  MEMBER_MERONYM = 'member meronym'
  SUBSTANCE_MERONYM = 'substance meronym'
  PART_MERONYM = 'part meronym'
  MEMBER_HOLONYM = 'member holonym'
  SUBSTANCE_HOLONYM = 'substance holonym'
  PART_HOLONYM = 'part holonym'
  SIMILAR = 'similar'
  PARTICIPLE_OF = 'participle of'
  PERTAINYM = 'pertainym'
  FRAMES = 'frames'
  CLASSIF_CATEGORY = 'domain category'
  CLASSIF_USAGE = 'domain usage'
  CLASSIF_REGIONAL = 'domain region'
  CLASS_CATEGORY = 'class category'
  CLASS_USAGE = 'class usage'
  CLASS_REGIONAL = 'class region'
  INSTANCE_HYPERNYM = 'hypernym (instance)'
  INSTANCE_HYPONYM = 'hyponym (instance)'
  POINTER_TYPES = ('antonym', 'hypernym', 'hyponym', 'attribute'...
  ATTRIBUTIVE = 'attributive'
  PREDICATIVE = 'predicative'
  IMMEDIATE_POSTNOMINAL = 'immediate postnominal'
  ADJECTIVE_POSITIONS = ('attributive', 'predicative', 'immediat...
  VERB_FRAME_STRINGS = (None, 'Something %s', 'Somebody %s', 'It...
  NOUN = 'noun'
  VERB = 'verb'
  ADJECTIVE = 'adj'
  ADVERB = 'adv'
  pos_abbrs = {'adj': 'adj.', 'adv': 'adv.', 'noun': 'n.', 'verb...
  _POSNormalizationTable = {'A': 'adj', 'ADJ': 'adj', 'ADJ.': 'a...
  FILE_OPEN_MODE = 'r'
  GET_INDEX_SUBSTITUTIONS = ((' ', '-'), ('-', ' '), ('-', ''), ...
  abbreviations = 'adverb adv adv. r'
  pos = 'adv'
  token = 'r'
  tokens = ['adverb', 'adv', 'adv.', 'r']
Function Details [hide private]

normalizePOS(pos)

source code 

Return the standard form of the supplied part of speech.

Parameters:
  • pos (string) - A (non-standard) part of speech string.
Returns:
A standard form part of speech string.

dataFilePathname(filenameroot)

source code 
Parameters:
  • filenameroot ({string}) - base form of the data file's filename.
Returns:
the full path to the data file.

binarySearchFile(file, key, cache={}, cacheDepth=-1)

source code 

Searches through a sorted file using the binary search algorithm.

Parameters:
  • file (file) - the file to be searched through.
  • key ({string}) - the identifier we are searching for.
Returns:
The line from the file with first word key.

getIndex(form, pos='noun')

source code 

Search for _form_ in the index file corresponding to _pos_. getIndex applies to _form_ 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_. The dictionary is looked up for each transformed string until a match is found or all the different strings have been tried. It returns a Word or None.


Variables Details [hide private]

POINTER_TYPES

Value:
('antonym',
 'hypernym',
 'hyponym',
 'attribute',
 'also see',
 'entailment',
 'cause',
 'verb group',
...

ADJECTIVE_POSITIONS

Value:
('attributive', 'predicative', 'immediate postnominal', None)

VERB_FRAME_STRINGS

Value:
(None,
 'Something %s',
 'Somebody %s',
 'It is %sing',
 'Something is %sing PP',
 'Something %s something Adjective/Noun',
 'Something %s Adjective/Noun',
 'Somebody %s Adjective',
...

pos_abbrs

Value:
{'adj': 'adj.', 'adv': 'adv.', 'noun': 'n.', 'verb': 'v.'}

_POSNormalizationTable

Value:
{'A': 'adj',
 'ADJ': 'adj',
 'ADJ.': 'adj',
 'ADJECTIVE': 'adj',
 'ADV': 'adv',
 'ADV.': 'adv',
 'ADVERB': 'adv',
 'N': 'noun',
...

GET_INDEX_SUBSTITUTIONS

Value:
((' ', '-'), ('-', ' '), ('-', ''), (' ', ''), ('.', ''))