Package nltk_lite :: Package contrib :: Package toolbox :: Module lexicon :: Class Entry
[hide private]
[frames] | no frames]

Class Entry

source code

This class represents an entry (record) from a Toolbox lexicon. Each entry consists of a collection of fields, stored as a special type of dictionary which keeps track of the sequence in which its keys were entered.

Instance Methods [hide private]
 
__init__(self)
This method constructs a new Entry object.
source code
string
__str__(self)
This method defines the string representation of an entry.
source code
 
set_raw_text(self, rawText)
This method provides access to the raw text from which the Entry object was parsed.
source code
string
get_raw_text(self)
This method sets the raw text from which the Entry object was parsed.
source code
list of Entry objects
get_subentries(self)
This method obtains all of the subentries for an entry.
source code
 
add_subentry(self, subentry)
This method adds to an entry a subentry, which is simply another Entry object.
source code
 
set_number(self, number)
This method sets the position of the entry in the dictionary as a cardinal number.
source code
integer
get_number(self)
This method obtains the position of the entry in the dictionary as a cardinal number.
source code
list of Field objects
get_fields(self)
This method obtains all of the fields found in the Entry object.
source code
list
get_field_markers(self)
This method obtains of the field markers found in the Entry object.
source code
 
get_values_by_marker(self, field_marker, sep=None) source code
string (if sep); otherwise, list of Field objects
get_field_values_by_field_marker(self, field_marker, sep=None)
This method returns all of the field values for a given field marker.
source code
string
get_field_as_string(self, field_marker, join_string='')
This method returns a particular field given a field marker.
source code
Field object
get_field(self, fieldMarker)
This method returns a particular field given a field marker.
source code
 
set_field(self, fieldMarker, field)
This method sets a field, given a marker and its associated data.
source code
 
set_field_values(self, fieldMarker, fieldValues)
This method sets all of the values associated with a field.
source code
 
add_field(self, marker, value)
This method adds a field to an entry if it does not already exist and adds a new value to the field of an entry if it does.
source code
 
remove_field(self, fieldMarker)
This method removes from an entry every field for a given field marker.
source code
Method Details [hide private]

__str__(self)
(Informal representation operator)

source code 

This method defines the string representation of an entry.

Returns: string
an entry as a string in Standard Format

set_raw_text(self, rawText)

source code 

This method provides access to the raw text from which the Entry object was parsed.

Parameters:
  • rawText (string) - raw Toolbox text from which entry was parsed

get_subentries(self)

source code 

This method obtains all of the subentries for an entry.

Returns: list of Entry objects
all of the subentries of an entry

add_subentry(self, subentry)

source code 

This method adds to an entry a subentry, which is simply another Entry object.

Parameters:
  • subentry (Entry object :) - subentry

set_number(self, number)

source code 

This method sets the position of the entry in the dictionary as a cardinal number.

Parameters:
  • number (integer) - number of entry

get_field_markers(self)

source code 

This method obtains of the field markers found in the Entry object.

Returns: list
the field markers of an entry

get_field_values_by_field_marker(self, field_marker, sep=None)

source code 

This method returns all of the field values for a given field marker. If the L(sep) is set, it will return a string; otherwise, it will return a list of Field objects.

Parameters:
  • field_marker (string) - marker of desired field
  • sep (string) - separator for field values
Returns: string (if sep); otherwise, list of Field objects

get_field_as_string(self, field_marker, join_string='')

source code 

This method returns a particular field given a field marker. Returns a blank string if field is not found.

Parameters:
  • field_marker (string) - marker of desired field
  • join_string (string) - string used to join field values (default to blank string)
Returns: string

get_field(self, fieldMarker)

source code 

This method returns a particular field given a field marker.

Parameters:
  • fieldMarker (string) - marker of desired field
Returns: Field object

set_field(self, fieldMarker, field)

source code 

This method sets a field, given a marker and its associated data.

Parameters:
  • fieldMarker (string) - field marker to set
  • field (Field) - field object associated with field marker

set_field_values(self, fieldMarker, fieldValues)

source code 

This method sets all of the values associated with a field.

Parameters:
  • fieldMarker (string) - field marker to set
  • fieldValues (list) - list of field values

add_field(self, marker, value)

source code 

This method adds a field to an entry if it does not already exist and adds a new value to the field of an entry if it does.

Parameters:
  • marker (string) - field marker
  • value (string) - field value

remove_field(self, fieldMarker)

source code 

This method removes from an entry every field for a given field marker. It will not raise an error if the specified field does not exist.

Parameters:
  • fieldMarker (string) - field marker to be deleted