Skip to content

LexDbInitialize

BenjaminWaldron edited this page Dec 13, 2006 · 24 revisions

HOW TO initialize LexDB

  • Obtain lexicon in LexDB dump format
  • Create skeletal LexDB
  • Populate LexDB
  • Set LKB lexicon to LexDB

Obtain lexicon in LexDB dump format

Either

  • you have an existing grammar for which these are provided; or
  • you must convert TDL lexicon (files) to LexDB dump format.

Convert TDL lexicon to LexDB dump format

(Note: only for the purpose of initializing the database contents. You must create a skeletal LexDB first -- see below.)

Follow these steps to generate dump files (.rev, .dfn, .fld, .meta) from an existing .tdl lexicon :

  • Run the LKB.

  • Load the grammar with the existing .tdl lexicon file(s) in normal manner.

  • Connect to the skeletal LexDB: (lkb::initialize-lexdb :dbname "erg")

  • Evaluate (lkb::export-lexicon) to create LexDB dump files. (You will be asked to provide values for certain meta-level database fields.)

The dump files will then be created in your "LKB temp" directory. Any entries which could not be exported (eg. their structure could not be fully described using the mapping in the .dfn field mapping file) will appear in a corresponding .skip file (which can be treated as a standard TDL lexicon file).

(Note: If the grammar contains more than one lexicon each will be dumped separately.)

HOW TO create skeletal LexDB

You must create a new database to hold the LexDB. The LexDB-specific database structures must then be initialized. For the purpose of these instructions assume the LexDB will be called erg with LexDB config files ~/erg/lexdb.*; if you do not yet have a .fld and a .dfn file you must create these before proceeding (see LexDbFieldMappings).

  • At shell prompt (M$ Windows users will need Cygwin):
 $ cd lkb/lexdb
 $ bash install-lexdb.sh erg ~/erg/lexdb.fld ~/erg/lexdb.dfn

(Note: The encoding for the lexical database will be set to UNICODE.)

  • You can view the field mappings in the field dfn just to make sure:
erg=> select * from dfn;
 mode | slot  |   field    |               path               |    type
------+-------+------------+----------------------------------+-------------
 erg  | id    | name          |                                  | symbol
 erg  | orth  | orthography   |                                  | string-list
 erg  | unifs | alt2key       | (synsem lkeys alt2keyrel pred)   | mixed
 erg  | unifs | altkey        | (synsem lkeys altkeyrel pred)    | mixed
 erg  | unifs | altkeytag     | (synsem lkeys altkeyrel carg)    | string
 erg  | unifs | compkey       | (synsem lkeys --compkey)         | symbol
 erg  | unifs | keyrel        | (synsem lkeys keyrel pred)       | mixed
 erg  | unifs | keytag        | (synsem lkeys keyrel carg)       | string
 erg  | unifs | ocompkey      | (synsem lkeys --ocompkey)        | symbol
 erg  | unifs | orthography   | (stem)                           | string-fs
 erg  | unifs | pronunciation | (synsem phon onset)              | symbol
 erg  | unifs | type          | nil                              | symbol
(10 rows)

erg=>

== HOW TO populate LexDB using dump files==

After performing the above initialization steps you have an empty database skeleton. This must be populated using existing dump files (.rev, .dfn, .fld, .meta).

  • Run the LKB.

  • Load the grammar script file, ensuring LKB lexicon is set to LexDB (below).

  • From LexDB menu (Options->Expand Menu), select Merge new entries and choose the lexdb.rev file to load.

(The final step copies the contents of lexdb.rev into the database table public.rev. You can view this table using the tool LexDbPgAccess.)

HOW TO set LKB lexicon to LexDB

The LexDB functions as an alternative to the textual lexicon.tdl file. The lexical database functionality is configured via the LKB user parameter *lexdb-params* (LKB menu->Options->Set Options).

Specify the name of the lexical database we will connect to:

   lkb::*lexdb-params* : ((:dbname "erg"))

In addition to :dbname, the following may also be set:

  • :user - username for database server login - default is your shell login

  • :port - port of database server - defaults to PGPORT

  • :host - specify a non-local host

  • :table - specify active mode (see dfn table) - default is value of :dbname

  • Edit the script file to replace call of form

{{{ (read-cached-lex-if-available

  • (list

    • (lkb-pathname (parent-directory) "lexicon.tdl")

    ))}}}

with the following

{{{ ;; optionally, use a lexical database;

  • ;; to activate the DB set *lexdb-params* (see globals.lsp) (if *lexdb-params*
    • (load-lexdb-from-script) (read-cached-lex-if-available
      • (list
        • (lkb-pathname (parent-directory) "lexicon.tdl") )))}}}
  • Load the grammar using modified script file.
Clone this wiki locally