module documentation

A WordNet Browser application which launches the default browser (if it is not already running) and opens a new tab with a connection to http://localhost:port/ . It also starts an HTTP server on the specified port and begins serving browser requests. The default port is 8000. (For command-line help, run "python wordnet -h") This application requires that the user's web browser supports Javascript.

BrowServer is a server for browsing the NLTK Wordnet database It first launches a browser client to be used for browsing and then starts serving the requests of that and maybe other clients

Usage:

browserver.py -h
browserver.py [-s] [-p <port>]

Options:

-h or --help
    Display this help message.

-l <file> or --log-file <file>
    Logs messages to the given file, If this option is not specified
    messages are silently dropped.

-p <port> or --port <port>
    Run the web server on this TCP port, defaults to 8000.

-s or --server-mode
    Do not start a web browser, and do not allow a user to
    shotdown the server through the web interface.
Class MyServerHandler Undocumented
Class Reference A reference to a page that may be generated by page_word
Function app Undocumented
Function get_relations_data Get synset relations data for a synset. Note that this doesn't yet support things such as full hyponym vs direct hyponym.
Function get_static_index_page Get the static index page.
Function get_static_page_by_path Return a static HTML page from the path given.
Function get_static_upper_page Return the upper frame page,
Function get_static_web_help_page Return the static web help page.
Function get_static_welcome_message Get the static welcome page.
Function get_unique_counter_from_url Extract the unique counter from the URL if it has one. Otherwise return null.
Function lemma_property Undocumented
Function make_lookup_link Undocumented
Function page_from_href Returns a tuple of the HTML page built and the new current word
Function page_from_reference Returns a tuple of the HTML page built and the new current word
Function page_from_word Return a HTML page for the given word.
Function pg Return a HTML page of NLTK Browser format constructed from the word and body
Function rebuild_tree Undocumented
Function startBrowser Undocumented
Function usage Display the command line help message.
Function wnb Run NLTK Wordnet Browser Server.
Constant ALSO_SEE Undocumented
Constant ANTONYM Undocumented
Constant ATTRIBUTE Undocumented
Constant CAUSE Undocumented
Constant DERIVATIONALLY_RELATED_FORM Undocumented
Constant ENTAILMENT Undocumented
Constant FRAMES Undocumented
Constant HYPERNYM Undocumented
Constant HYPONYM Undocumented
Constant INDIRECT_HYPERNYMS Undocumented
Constant INSTANCE_HYPERNYM Undocumented
Constant INSTANCE_HYPONYM Undocumented
Constant MEMBER_HOLONYM Undocumented
Constant MEMBER_MERONYM Undocumented
Constant PART_HOLONYM Undocumented
Constant PART_MERONYM Undocumented
Constant PERTAINYM Undocumented
Constant SIMILAR Undocumented
Constant SUBSTANCE_HOLONYM Undocumented
Constant SUBSTANCE_MERONYM Undocumented
Constant VERB_GROUP Undocumented
Variable CLASS_CATEGORY Undocumented
Variable CLASS_REGIONAL Undocumented
Variable CLASS_USAGE Undocumented
Variable explanation Undocumented
Variable firstClient Undocumented
Variable full_hyponym_cont_text Undocumented
Variable html_header Undocumented
Variable html_trailer Undocumented
Variable logfile Undocumented
Variable server_mode Undocumented
Function _abbc abbc = asterisks, breaks, bold, center
Function _bold Undocumented
Function _center Undocumented
Function _collect_all_synsets Return a HTML unordered list of synsets for the given word and part of speech.
Function _collect_one_synset Returns the HTML string for one synset or word
Function _get_synset The synset key is the unique name of the synset, this can be retrived via synset.name()
Function _hlev Undocumented
Function _italic Undocumented
Function _li Undocumented
Function _pos_match This function returns the complete pos tuple for the partial pos tuple given to it. It attempts to match it against the first non-null component of the given pos tuple.
Function _pos_tuples Undocumented
Function _synset_relations Builds the HTML string for the relations of a synset
Function _ul Undocumented
def app(): (source)

Undocumented

def get_relations_data(word, synset): (source)

Get synset relations data for a synset. Note that this doesn't yet support things such as full hyponym vs direct hyponym.

def get_static_index_page(with_shutdown): (source)

Get the static index page.

def get_static_page_by_path(path): (source)

Return a static HTML page from the path given.

def get_static_upper_page(with_shutdown): (source)

Return the upper frame page,

If with_shutdown is True then a 'shutdown' button is also provided to shutdown the server.

def get_static_web_help_page(): (source)

Return the static web help page.

def get_static_welcome_message(): (source)

Get the static welcome page.

def get_unique_counter_from_url(sp): (source)

Extract the unique counter from the URL if it has one. Otherwise return null.

def lemma_property(word, synset, func): (source)

Undocumented

def make_lookup_link(ref, label): (source)

Undocumented

def page_from_href(href): (source)

Returns a tuple of the HTML page built and the new current word

Parameters
href:strThe hypertext reference to be solved
Returns
A tuple (str,str)A tuple (page,word), where page is the new current HTML page to be sent to the browser and word is the new current word
def page_from_reference(href): (source)

Returns a tuple of the HTML page built and the new current word

Parameters
href:strThe hypertext reference to be solved
Returns
A tuple (str,str)A tuple (page,word), where page is the new current HTML page to be sent to the browser and word is the new current word
def page_from_word(word): (source)

Return a HTML page for the given word.

Parameters
word:strThe currently active word
Returns
A tuple (str,str)A tuple (page,word), where page is the new current HTML page to be sent to the browser and word is the new current word
def pg(word, body): (source)

Return a HTML page of NLTK Browser format constructed from the word and body

Parameters
word:strThe word that the body corresponds to
body:strThe HTML body corresponding to the word
Returns
stra HTML page for the word-body combination
def rebuild_tree(orig_tree): (source)

Undocumented

def startBrowser(url, server_ready): (source)

Undocumented

def usage(): (source)

Display the command line help message.

def wnb(port=8000, runBrowser=True, logfilename=None): (source)

Run NLTK Wordnet Browser Server.

Parameters
port:intThe port number for the server to listen on, defaults to 8000
runBrowser:boolTrue to start a web browser and point it at the web server.
logfilenameUndocumented
ALSO_SEE: int = (source)

Undocumented

Value
15
ANTONYM: int = (source)

Undocumented

Value
18
ATTRIBUTE: int = (source)

Undocumented

Value
5
CAUSE: int = (source)

Undocumented

Value
14
DERIVATIONALLY_RELATED_FORM: int = (source)

Undocumented

Value
25
ENTAILMENT: int = (source)

Undocumented

Value
17
FRAMES: int = (source)

Undocumented

Value
19
HYPERNYM: int = (source)

Undocumented

Value
1
HYPONYM: int = (source)

Undocumented

Value
0
INDIRECT_HYPERNYMS: int = (source)

Undocumented

Value
26
INSTANCE_HYPERNYM: int = (source)

Undocumented

Value
13
INSTANCE_HYPONYM: int = (source)

Undocumented

Value
12
MEMBER_HOLONYM: int = (source)

Undocumented

Value
8
MEMBER_MERONYM: int = (source)

Undocumented

Value
9
PART_HOLONYM: int = (source)

Undocumented

Value
3
PART_MERONYM: int = (source)

Undocumented

Value
4
PERTAINYM: int = (source)

Undocumented

Value
20
SIMILAR: int = (source)

Undocumented

Value
16
SUBSTANCE_HOLONYM: int = (source)

Undocumented

Value
6
SUBSTANCE_MERONYM: int = (source)

Undocumented

Value
7
VERB_GROUP: int = (source)

Undocumented

Value
10
CLASS_CATEGORY: int = (source)

Undocumented

CLASS_REGIONAL: int = (source)

Undocumented

CLASS_USAGE: int = (source)

Undocumented

explanation: str = (source)

Undocumented

firstClient: bool = (source)

Undocumented

full_hyponym_cont_text = (source)

Undocumented

html_header: str = (source)

Undocumented

html_trailer: str = (source)

Undocumented

Undocumented

server_mode = (source)

Undocumented

def _abbc(txt): (source)

abbc = asterisks, breaks, bold, center

def _bold(txt): (source)

Undocumented

def _center(txt): (source)

Undocumented

def _collect_all_synsets(word, pos, synset_relations=dict()): (source)

Return a HTML unordered list of synsets for the given word and part of speech.

def _collect_one_synset(word, synset, synset_relations): (source)

Returns the HTML string for one synset or word

to display. :type synset_relations: dict(synset_key, set(relation_id)) :return: The HTML string built for this synset :rtype: str

Parameters
word:strthe current word
synset:synseta synset
synset_relationsinformation about which synset relations
def _get_synset(synset_key): (source)

The synset key is the unique name of the synset, this can be retrived via synset.name()

def _hlev(n, txt): (source)

Undocumented

def _italic(txt): (source)

Undocumented

def _li(txt): (source)

Undocumented

def _pos_match(pos_tuple): (source)

This function returns the complete pos tuple for the partial pos tuple given to it. It attempts to match it against the first non-null component of the given pos tuple.

def _pos_tuples(): (source)

Undocumented

def _synset_relations(word, synset, synset_relations): (source)

Builds the HTML string for the relations of a synset

Parameters
word:strThe current word
synset:SynsetThe synset for which we're building the relations.
synset_relations:dict(synset_key, set(relation_type))synset keys and relation types for which to display relations.
Returns
strThe HTML for a synset's relations
def _ul(txt): (source)

Undocumented