Changeset 35495 in project


Ignore:
Timestamp:
04/30/18 11:52:00 (6 months ago)
Author:
svnwiki
Message:

Anonymous wiki edit for IP [220.233.44.123]:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/link-grammar

    r35161 r35495  
     1== link-grammar
     2
     3Bindings for the CMU link-grammar parser system.
    14[[toc:]]
    2 
    3 
    4 == link grammar
    5 
    6 Chicken bindings to the [[http://www.link.cs.cmu.edu/link/|CMU link grammar parser]].
    7 
    8 
    9 === Description
    10 
    11 The link grammar parser is a syntactic parser of English, based on link grammar, an original theory of English syntax. Given a sentence, the system assigns to it a syntactic structure, which consists of a set of labeled links connecting pairs of words. The parser also produces a "constituent" representation of a sentence (showing noun phrases, verb phrases, etc.).
    12 
    13 === Project / Source Code Repository
    14 
     5=== Link Grammar
     6The link grammar parser is a syntactic parser of English, based on
     7link grammar, an original theory of English syntax. Given a sentence
     8the system assigns to it a syntactic structure, which consists of a
     9set of labeled links connecting pairs of words. The parser also
     10produces a 'constituent' representation of a sentence (showing noun
     11phrases, verb phrases, etc.).
     12
     13
     14=== Documentation
     15=== Project Source Code
    1516[[https://gitlab.com/maxwell79/chicken-link-grammar]]
    1617
    1718
    18 === Maintainer
    19 
    20 David Ireland (djireland79 at gmail dot com)
    21 
    22 == Example
    23 
    24 <enscript highlight="scheme">
    25 (use (prefix link-grammar lg:))
    26 
     19==== {{link-grammar}}
     20'''[module]''' {{link-grammar}}
     21
     221.3
     23* [[#parse-with-default]]
     24* [[#parse-sentence]]
     25* [[#display-off]]
     26* [[#display-multi-line]]
     27* [[#display-bracket-tree]]
     28* [[#display-single-line]]
     29* [[#display-max-styles]]
     30* [[#create-default-dictionary]]
     31* [[#create-dictionary-with-language]]
     32* [[#get-verbosity]]
     33* [[#get-version]]
     34* [[#get-dictionary-version]]
     35* [[#get-dictionary-locale]]
     36* [[#get-dictionary-language]]
     37* [[#get-dictionary-data-dir]]
     38* [[#set-dictionary-data-dir!]]
     39* [[#delete-dictionary!]]
     40* [[#create-sentence]]
     41* [[#split-sentence]]
     42* [[#sentence-length]]
     43* [[#sentence-null-count]]
     44* [[#sentence-disjunct-cost]]
     45* [[#sentence-link-cost]]
     46* [[#linkages-found]]
     47* [[#linkages-post-processed]]
     48* [[#linkages-violated]]
     49* [[#valid-linkages]]
     50* [[#delete-sentence!]]
     51* [[#create-linkage]]
     52* [[#corpus-cost]]
     53* [[#get-lword]]
     54* [[#get-rword]]
     55* [[#get-words]]
     56* [[#get-word]]
     57* [[#get-constituents]]
     58* [[#get-diagram]]
     59* [[#get-postscript]]
     60* [[#get-disjuncts]]
     61* [[#get-links-domains]]
     62* [[#get-violation-name]]
     63* [[#link-length]]
     64* [[#link-label]]
     65* [[#link-llabel]]
     66* [[#link-rlabel]]
     67* [[#link-cost]]
     68* [[#link-domain-names]]
     69* [[#num-words]]
     70* [[#num-links]]
     71* [[#num-domains]]
     72* [[#unused-word-cost]]
     73* [[#delete-linkage!]]
     74* [[#init-opts]]
     75* [[#set-max-parse-time!]]
     76* [[#set-linkage-limit!]]
     77* [[#set-short-length!]]
     78* [[#set-disjunct-cost!]]
     79* [[#set-min-null-count!]]
     80* [[#set-max-null-count!]]
     81* [[#set-max-parse-time!]]
     82* [[#set-islands-ok!]]
     83* [[#set-verbosity!]]
     84* [[#resources-exhausted?]]
     85* [[#memory-exhausted?]]
     86* [[#timer-expired?]]
     87* [[#reset-resources!]]
     88* [[#delete-parse-options!]]
     89=== Example Usage
     90<enscript highlight="scheme">(use (prefix link-grammar lg:))
    2791(define (display-linkage sentence opts index)
    28   (let* ([links-found (lg:linkages-found sentence)]
    29          [linkage (lg:create-linkage index sentence opts)])
     92  (let* ((links-found (lg:linkages-found sentence))
     93         (linkage (lg:create-linkage index sentence opts)))
    3094    (when linkage
    31       (begin
    32         (let ([constituents (lg:get-constituents linkage lg:MAX-STYLES)]
    33               [diagram      (lg:get-diagram linkage #t 80)])
    34           (print constituents)
    35           (print diagram)
    36           (lg:delete-linkage! linkage))))
    37     (when (<= index links-found)
    38       (display-linkage sentence opts (+ index 1)))))
    39  
     95          (let ((constituents
     96                  (lg:get-constituents linkage lg:display-multi-line))
     97                (diagram (lg:get-diagram linkage #t 80)))
     98            (print constituents)
     99            (print diagram)
     100            (lg:delete-linkage! linkage)))
     101    (when (<= index links-found) (display-linkage sentence opts (+ index 1)))))
    40102(define (parse text dictionary opts)
    41   (let* ([sentence     (lg:create-sentence text dictionary)]
    42          [num-linkages (lg:parse-sentence sentence opts)])
     103  (let* ((sentence (lg:create-sentence text dictionary))
     104         (num-linkages (lg:parse-sentence sentence opts)))
    43105    (when (= num-linkages 0)
    44       (begin
    45        (lg:set-min-null-count! opts  1)
    46        (lg:set-max-null-count! opts (lg:sentence-length sentence))
    47        (set! num-linkages (lg:parse-sentence sentence opts))))
     106          (lg:set-min-null-count! opts 1)
     107          (lg:set-max-null-count! opts (lg:sentence-length sentence))
     108          (set! num-linkages (lg:parse-sentence sentence opts)))
    48109    (display-linkage sentence opts 0)
    49110    (lg:delete-sentence! sentence)))
    50 
    51 
    52 ; Main Entry
    53111(define dictionary (lg:create-default-dictionary))
    54 (define opts       (lg:init-opts))
    55 
    56 (lg:set-linkage-limit!  opts 1000)
    57 (lg:set-short-length!   opts 10)
    58 (lg:set-verbosity!      opts 1)
     112(define opts (lg:init-opts))
     113(lg:set-linkage-limit! opts 1000)
     114(lg:set-short-length! opts 10)
     115(lg:set-verbosity! opts 1)
    59116(lg:set-max-parse-time! opts 30)
    60 (lg:set-linkage-limit!  opts 1000)
     117(lg:set-linkage-limit! opts 1000)
    61118(lg:set-min-null-count! opts 0)
    62119(lg:set-max-null-count! opts 0)
    63 (lg:set-short-length!   opts 16)
    64 (lg:set-islands-ok!     opts #f)
    65 
     120(lg:set-short-length! opts 16)
     121(lg:set-islands-ok! opts #f)
    66122(parse "The black fox ran from the hunters" dictionary opts)
    67123(lg:delete-parse-options! opts)
    68124(lg:delete-dictionary! dictionary)
    69125</enscript>
    70 
    71 
    72 '''Produces the following output:'''
    73 
    74  (S (NP the black.a fox.n)
    75     (VP ran.v-d
    76         (PP from
    77             (NP the hunters.n))))
    78 
    79     +------------------------Xp------------------------+       
    80     +----------->WV----------->+                       |       
    81     +---------Wd--------+      |                       |       
    82     |      +----Ds**x---+      |      +----Jp----+     |       
    83     |      |     +---A--+--Ss--+--MVp-+   +--Dmc-+     +--RW--+
    84     |      |     |      |      |      |   |      |     |      |
    85  LEFT-WALL the black.a fox.n ran.v-d from the hunters.n . RIGHT-WALL
    86 
    87  (S (NP the black.a fox.n)
    88     (VP ran.v-d
    89         (PP from
    90             (NP the hunters.n))))
    91  
    92     +------------------------Xp------------------------+       
    93     +---------Wd--------+                              |       
    94     |      +----Ds**x---+             +----Jp----+     |       
    95     |      |     +---A--+--Ss--+--MVp-+   +--Dmc-+     +--RW--+
    96     |      |     |      |      |      |   |      |     |      |
    97  LEFT-WALL the black.a fox.n ran.v-d from the hunters.n . RIGHT-WALL
    98 
    99 == API
    100 
    101 
    102 === System Information
    103 
    104 
    105 <procedure>(get-version) -> string</procedure>
    106 <procedure>(get-dictionary-version dictionary*) -> string</procedure>
    107 <procedure>(get-dictionary-locale) dictionary*) -> string</procedure>
    108 
    109 
    110 === Constants
    111 
    112 ==== Displaying Constituents
    113 
    114 <constant>NO-DISPLAY</constant>
    115 <constant>NO-MULTI-LINE</constant>
    116 <constant>NO-BRACKET-TREE</constant>
    117 <constant>NO-SINGLE-LINE</constant>
    118 <constant>NO-MAX-STYLES</constant>
    119 
    120 ==== Error Handling
    121 
    122 <constant>FATAL</constant>
    123 <constant>ERROR</constant>
    124 <constant>WARN</constant>
    125 <constant>INFO</constant>
    126 <constant>DEBUG</constant>
    127 <constant>TRACE</constant>
    128 <constant>NONE</constant>
    129 
    130 
     126  (S (NP the black.a fox.n)
     127             (VP ran.v-d
     128                 (PP from
     129                     (NP the hunters.n))))
     130
     131
     132  +------------------------Xp------------------------+       
     133  +----------->WV----------->+                       |       
     134  +---------Wd--------+      |                       |       
     135  |      +----Ds**x---+      |      +----Jp----+     |       
     136  |      |     +---A--+--Ss--+--MVp-+   +--Dmc-+     +--RW--+
     137  |      |     |      |      |      |   |      |     |      |
     138  LEFT-WALL the black.a fox.n ran.v-d from the hunters.n . RIGHT-WALL
     139
     140  (S (NP the black.a fox.n)
     141     (VP ran.v-d
     142         (PP from
     143             (NP the hunters.n))))
     144
     145
     146  +------------------------Xp------------------------+       
     147  +---------Wd--------+                              |       
     148  |      +----Ds**x---+             +----Jp----+     |       
     149  |      |     +---A--+--Ss--+--MVp-+   +--Dmc-+     +--RW--+
     150  |      |     |      |      |      |   |      |     |      |
     151  LEFT-WALL the black.a fox.n ran.v-d from the hunters.n . RIGHT-WALL
     152
     153
     154=== Simple Use
     155Parse a text using default values for the dictionary and parser
     156
     157
     158==== {{parse-with-default}}
     159<procedure>(parse-with-default text) → (values words links diagrams postscript)</procedure>
     160Parse text using default values
     161; {{text}} : string to parse
     162=== Sentences
     163A sentence is the API's representation of an input string, tokenized
     164and interpreted according to a specific Dictionary. After a Sentence is created
     165and parsed, various attributes of the resulting set of linkages can be
     166obtained.
     167
     168
     169==== {{create-sentence}}
     170<procedure>(create-sentence input dictionary) → sentence</procedure>
     171creates a sentence object from the input string, using the Dictionary that
     172was created earlier to tokenize and define words
     173; {{input}} : Input string  (string)
     174; {{dictionary}} : dictionary to use
     175==== {{delete-sentence!}}
     176<procedure>(delete-sentence! sentence) → unspecified</procedure>
     177Deletes the specificed sentence
     178; {{sentence}} : Sentence to be deleted (sentence)
     179==== {{split-sentence}}
     180<procedure>(split-sentence sentence parse-options) → number</procedure>
     181Splits (tokenizes) the sentence up into its component words and
     182punctuation. This includes splitting up certain run-on expressions,
     183such as '12ft.' which is split into '12' and 'ft.'. If spell-
     184guessing is enabled in the opts, the tokenizer will also separate
     185most run-on words, i.e. pairs of words without an intervening space.
     186This routine returns zero if successful; else a non-zero value if an error
     187occurred.
     188; {{sentence}} : Sentence to split (sentence)
     189; {{parse-options}} :
     190==== {{parse-sentence}}
     191<procedure>(parse-sentence sentence parse-options) → number</procedure>
     192This routine represents the heart of the program. There are several things
     193that are done when a sentence is parsed:
     1941. Word expressions are extracted from the dictionary and pruned.
     1952. Disjuncts are built.
     1963. A series of pruning operations is carried out.
     1974. The linkages having the minimal number of null links are counted.
     1985. A 'parse set' of linkages is built.
     1996. The linkages are post-processed.
     200
     201The 'parse set' is attached to the sentence, and this is one of the key
     202reasons that the API is flexible and modular. All of the necessary
     203information for building linkages is stored in the parse set. This means
     204that other sentences can be parsed, possibly using different dictionaries
     205and other parameters, without disturbing the information obtained from a
     206call to sentence_parse. If another call to parse-sentence is made on the
     207same sentence, the parsing information for the previous call is deleted.
     208Like almost all of the other routines, this call is thread-safe: that
     209is, sentences can be parsed concurrently in multiple threads.
     210; {{sentence}} :
     211; {{parse-options}} :
     212==== {{sentence-length}}
     213<procedure>(sentence-length sentence) → number</procedure>
     214Returns the length of the sentence
     215; {{sentence}} :
     216==== {{sentence-null-count}}
     217<procedure>(sentence-null-count) → number</procedure>
     218Returns the number of words that failed to be linked into the rest of the
     219sentence during parsing. This number is greater then zero whenever a word
     220doesn't seem to fit anywhere in the parse, either due to poor grammar, or
     221due to a shortcoming of the dictionary.
     222
     223==== {{linkages-found}}
     224<procedure>(linkages-found) → number</procedure>
     225Returns the number of linkages that the search found
     226
     227==== {{valid-linkages}}
     228<procedure>(valid-linkages) → number</procedure>
     229Returns the number of linkages that had no post-processing violations
     230
     231==== {{linkages-post-processed}}
     232<procedure>(linkages-post-processed) → number</procedure>
     233Returns the number of linkages that were actually post-processed
     234
     235==== {{linkages-violated}}
     236<procedure>(linkages-violated) → number</procedure>
     237Returns the number of post-processing violations that the i-th linkage had
     238
     239during the last call to sentence_parse.
     240
     241==== {{sentence-disjunct-cost}}
     242<procedure>(sentence-disjunct-cost sentence index) → number</procedure>
     243Returns the sum total of all of the costs of all of the disjuncts used in
     244the i-th linkage of the sentence. The higher the cost, the less likely that the
     245parse is correct. Very roughly, this can be interpreted as if it was (minus)
     246the log-liklihood of a parse being correct.
     247; {{sentence}} :
     248; {{index}} :
     249==== {{sentence-link-cost}}
     250<procedure>(sentence-link-cost sentence index) → number</procedure>
     251Returns the sum of the length of the links in the i-th parse. The ratio of
     252this length, to the total length of the sentence, gives a rough measure of
     253the complexity of the sentence. That is, long-range links between distant
     254words indicates that the sentence may be hard to understand; alternately,
     255it may indicate that the parse is not very accurate.
     256; {{sentence}} :
     257; {{index}} :
    131258=== Dictionary
    132 
    133 
    134 <procedure>(create-default-dictionary)              -> dictionary*</procedure>
    135 <procedure>(create-dictionary-from-utf8 string)     -> dictionary*</procedure>
    136 <procedure>(create-dictionary-with-language string) -> dictionary*</procedure>
    137 <procedure>(get-dictionary-language dictionary*)    -> string</procedure>
    138 <procedure>(get-dictionary-data-dir dictionary*)    -> string</procedure>
    139 <procedure>(set-dictionary-data-dir! string)</procedure>
    140 <procedure>(delete-dictionary! dictionary*) </procedure>
    141 
     259A Dictionary is the programmer's handle on the set of word definitions
     260that defines the grammar. A user creates a Dictionary from a grammar file and
     261post-process knowledge file, and then passes it to the various parsing
     262routines.
     263
     264
     265==== {{create-dictionary-with-language}}
     266<procedure>(create-dictionary-with-language language) → dictionary</procedure>
     267Creates a dictionary with the specified language
     268; {{language}} : Language to use (string)
     269==== {{create-default-dictionary}}
     270<procedure>(create-default-dictionary) → dictionary</procedure>
     271Looks for a dictionary in the same language as the current environment,
     272and if one is found, creates a dictionary object.
     273
     274==== {{get-dictionary-language}}
     275<procedure>(get-dictionary-language dictionary) → string</procedure>
     276Returns the language of the specified dictionary
     277; {{dictionary}} : specified dictionary (dictionary)
     278==== {{delete-dictionary!}}
     279<procedure>(delete-dictionary! dictionary) → unspecified</procedure>
     280Deletes the specified dictionary
     281; {{dictionary}} : specified dictionary (dictionary)
     282==== {{set-dictionary-data-dir!}}
     283<procedure>(set-dictionary-data-dir! path) → unspecified</procedure>
     284Specify the file path to the dictionaries to use; to be effective, this
     285routine must be called before the dictionaries are opened.
     286; {{path}} : Filename with path
     287==== {{get-dictionary-data-dir}}
     288<procedure>(get-dictionary-data-dir) → string</procedure>
     289Returns the file path to the dictionaries
     290
     291=== Linkages
     292==== {{create-linkage}}
     293<procedure>(create-linkage) → linkage</procedure>
     294This function creates the index-th linkage from the (parsed) sentence
     295sent. Several operations can be carried out on the resulting linkage;
     296for example it can be printed, post-processed with a different post-
     297processor, or information on individual links can be extracted. If
     298the parse has a conjunction, then the linkage will be made up of two or
     299more sublinkages.
     300
     301==== {{delete-linkage!}}
     302<procedure>(delete-linkage! linakge) → unspecified</procedure>
     303Delete the given linkage
     304; {{linakge}} :
     305==== {{num-words}}
     306<procedure>(num-words linkage) → number</procedure>
     307The number of words in the sentence for which this is a linkage.
     308; {{linkage}} :
     309==== {{num-links}}
     310<procedure>(num-links linkage) → number</procedure>
     311The number of links used in the linkage.
     312; {{linkage}} :
     313==== {{link-length}}
     314<procedure>(link-length linkage index) → number</procedure>
     315The value returned by num-links procedure is the number of words spanned
     316by the index-th link of the linkage.
     317; {{linkage}} :
     318; {{index}} : (number)
     319==== {{get-lword}}
     320<procedure>(get-lword) → number</procedure>
     321The value returned is the number of the word on the left end of the
     322index-th link of the current sublinkage.
     323
     324==== {{get-rword}}
     325<procedure>(get-rword) → number</procedure>
     326The value returned is the number of the word on the right end of the
     327index-th link of the current sublinkage.
     328
     329==== {{link-label}}
     330<procedure>(link-label linkage index) → string</procedure>
     331The label on a link in a diagram is constructed by taking the
     332'intersection' of the left and right connectors that comprise the link.
     333For example, 'I.p eat, therefore I.p think.v' has a  Sp*i label on the
     334link between the words I.p and eat is constructed from the Sp*i
     335connector on the its left word, and the Sp connector on its right word.
     336So, for this example, both link-label and link-llabel return 'Sp*i'
     337while link-rlabel returns 'Sp' for this link.
     338; {{linkage}} :
     339; {{index}} :
     340==== {{link-llabel}}
     341<procedure>(link-llabel linkage index) → string</procedure>
     342See link-label
     343; {{linkage}} :
     344; {{index}} :
     345==== {{link-rlabel}}
     346<procedure>(link-rlabel linkage index) → string</procedure>
     347See link-label
     348; {{linkage}} :
     349; {{index}} :
     350==== {{num-domains}}
     351<procedure>(num-domains linkage index) → number</procedure>
     352num-domains, link-domain-names allow access to most of
     353the domain structure extracted during post-processing. The index parameter
     354in the first two calls specify which link in the linkage to extract the
     355information for. In the 'I eat therefore I think' example above, the link
     356between the words therefore and I.p belongs to two 'm' domains. If the
     357linkage violated any post-processing rules, the name of the violated rule
     358in the post-process knowledge file can be determined by a call to
     359get-violation-name.
     360; {{linkage}} :
     361; {{index}} :
     362==== {{link-domain-names}}
     363<procedure>(link-domain-names linkage word-index) → list</procedure>
     364Gets domain structure extracted during the post-processing
     365; {{linkage}} :
     366; {{word-index}} : Specifies which link in the linkage to extract the  information for.
     367==== {{get-words}}
     368<procedure>(get-words linkage) → list</procedure>
     369Returns the array of word spellings or individual word spelling for the
     370linkage. These are the subscripted spellings, such as 'dog.n'. The original
     371spellings can be obtained by calls to sentence-get-word.
     372; {{linkage}} :
     373==== {{get-word}}
     374<procedure>(get-word linkage word-number) → string</procedure>
     375Returns the word spelling of an individual word
     376; {{linkage}} :
     377; {{word-number}} : The specific word
     378==== {{disjunct-str}}
     379<procedure>(disjunct-str linkage linkage word-number) → string</procedure>
     380Return a string showing the disjuncts that were actually used in
     381association with the specified word in the current linkage. The string
     382shows the disjuncts in proper order; that is, left-to-right, in the order
     383in which they link to other words. The returned string can be thought of
     384as a very precise part-of-speech-like label for the word, indicating how
     385it was used in the given sentence; this can be useful for corpus statistics.
     386; {{linkage}} : The specific linkage
     387; {{linkage}} :
     388; {{word-number}} : The specific word
     389==== {{disjunct-cost}}
     390<procedure>(disjunct-cost) → number</procedure>
     391Return the cost of a word as used in a particular linkage, based
     392     on the dictionary.
     393
     394==== {{disjunct-corpus-score}}
     395<procedure>(disjunct-corpus-score) → number</procedure>
     396Returns the cost based on the corpus-statistics database.
     397
     398==== {{get-constituents}}
     399<procedure>(get-constituents linkage display-style) → string</procedure>
     400Returns the constituents for a particular linkage
     401; {{linkage}} :
     402; {{display-style}} : (number
     403==== {{get-diagram}}
     404<procedure>(get-diagram linkage display-walls? screen-width) → string</procedure>
     405Returns the linkage diagram
     406; {{linkage}} :
     407; {{display-walls?}} : A boolean that indicates whether or not the wall-words, and the connectors to them, should be printed
     408; {{screen-width}} : The screen-width is an integer, indicating the number of columns that should be used during printing; long sentences that are wider than the number of columns will be automatically wrapped so that they always fit.
     409==== {{get-postscript}}
     410<procedure>(get-postscript linkage display-walls? print-ps-header?) → string</procedure>
     411Returns the macros needed to print out the linkage in a postscript file.
     412; {{linkage}} :
     413; {{display-walls?}} : A boolean that indicates whether or not the wall-words, and the connectors to them, should be printed
     414; {{print-ps-header?}} : A boolean that indicates whether or not postscript header boilerplate should be included.
     415==== {{get-disjuncts}}
     416<procedure>(get-disjuncts linkage) → string</procedure>
     417Returns the returns a string that shows all of the disjuncts, and their
     418costs, that were used to create the linkage.
     419; {{linkage}} :
     420==== {{get-links-domains}}
     421<procedure>(get-links-domains linkage) → string</procedure>
     422Returns a string that lists all of the links and domain names for the
     423linkage.
     424; {{linkage}} :
     425==== {{unused-word-cost}}
     426<procedure>(unused-word-cost linkage) → number</procedure>
     427Should return the same value as sentence-null-count.
     428; {{linkage}} :
     429==== {{disjunct-cost}}
     430<procedure>(disjunct-cost linkage) → number</procedure>
     431Should return the same value as sentence-disjunct-cost.
     432; {{linkage}} :
     433==== {{link-cost}}
     434<procedure>(link-cost linkage) → number</procedure>
     435Should return the same value as sentence-link-cost.
     436; {{linkage}} :
     437==== {{corpus-cost}}
     438<procedure>(corpus-cost linkage) → number</procedure>
     439Returns the total cost of this particular linkage, based on the cost of
     440disjuncts stored in the corpus-statistics database.
     441; {{linkage}} :
     442==== {{linkage->eps-file}}
     443<procedure>(linkage->eps-file filename postscript) → unspecified</procedure>
     444Saves a linkage to a postscript file
     445; {{path}} : filename
     446; {{postscript}} : Postscript string
     447==== {{get-version}}
     448<procedure>(get-version) → string</procedure>
     449Gets link-grammar version
     450
     451==== {{get-dictionary-version}}
     452<procedure>(get-dictionary-version dictionary) → string</procedure>
     453Gets dictionary version
     454; {{dictionary}} : Dictionary
     455==== {{get-dictionary-locale}}
     456<procedure>(get-dictionary-locale) → string</procedure>
     457Gets dictionary locale
     458
     459==== {{display-off}}
     460<constant>display-off → 0</constant>
     461Turn off display
     462==== {{display-multi-line}}
     463<constant>display-multi-line → 1</constant>
     464Print diagram across multiple lines
     465==== {{display-bracket-tree}}
     466<constant>display-bracket-tree → 2</constant>
     467Use brackets when printing diagram
     468==== {{display-single-line}}
     469<constant>display-single-line → 3</constant>
     470Print diagram on single line
     471==== {{display-max-styles}}
     472<constant>display-max-styles → 3</constant>
     473Print diagram on single line
     474==== {{set-display-morphology!}}
     475<procedure>(set-display-morphology! parse-options value) → unspecified</procedure>
     476Sets display morphology in parse-options
     477; {{parse-options}} :
     478; {{value}} : (number)
     479==== {{get-display-morphology}}
     480<procedure>(get-display-morphology parse-options) → number</procedure>
     481Gets display morphology value
     482; {{parse-options}} :
    142483=== Parse Options
    143 
    144 
    145 <procedure>(init-opts parse-options* int) -> parse-options* </procedure>
    146 <procedure>(set-max-parse-time! parse-options* int)</procedure>
    147 <procedure>(set-linkage-limit! parse-options* int)</procedure>
    148 <procedure>(set-short-length! parse-options* int)</procedure>
    149 <procedure>(set-disjunct-cost! parse-options* int)</procedure>
    150 <procedure>(set-min-null-count! parse-options* int)</procedure>
    151 <procedure>(set-max-null-count! parse-options* int)</procedure>
    152 <procedure>(set-max-parse-time! parse-options* int)</procedure>
    153 <procedure>(set-islands-ok! parse-options* bool)</procedure>
    154 <procedure>(set-verbosity! parse-options* int)</procedure>
    155 <procedure>(get-verbosity parse-options*) -> int </procedure>
    156 <procedure>(resources-exhausted? parse-options*) -> bool </procedure>
    157 <procedure>(memory-exhausted? parse-options*) -> bool </procedure>
    158 <procedure>(timer-expired? parse-options*) -> bool </procedure>
    159 <procedure>(reset-resources! parse-options*)</procedure>
    160 <procedure>(delete-parse-options! parse-options*)</procedure>
    161 
    162 
    163 === Sentences
    164 
    165 
    166 <procedure>(create-sentence string dictionary*) -> sentence* </procedure>
    167 <procedure>(split-sentence sentence* parse-options*) -> int</procedure>
    168 <procedure>(parse-sentence sentence* parse-options*) -> int</procedure>
    169 <procedure>(sentence-length sentence*) -> int</procedure>
    170 <procedure>(sentence-null-count sentence*) -> int</procedure>
    171 <procedure>(sentence-disjunct-cost sentence* int) -> int</procedure>
    172 <procedure>(sentence-link-cost sentence* int) -> int </procedure>
    173 <procedure>(linkages-found sentence*) -> int</procedure>
    174 <procedure>(linkages-post-processed sentence*) -> int</procedure>
    175 <procedure>(linkages-violated sentence* int) -> int</procedure>
    176 <procedure>(valid-linkages sentence*) -> int</procedure>
    177 <procedure>(delete-sentence! sentence*)</procedure>
    178                        
    179 === Linkages
    180 
    181 
    182 <procedure>(create-linkage int sentence* parse-options*) -> int </procedure>
    183 <procedure>(corpus-cost linkage*) -> double </procedure>
    184 <procedure>(get-lword linkage* int) -> int </procedure>
    185 <procedure>(get-rword linkage* int) -> int </procedure>
    186 <procedure>(get-words linkage*) -> list </procedure>
    187 <procedure>(get-word linkage* int) -> string </procedure>
    188 <procedure>(get-constituents linkage* int) -> string </procedure>
    189 <procedure>(get-diagram linkage* bool int) -> string</procedure>
    190 <procedure>(get-postscript linkage* bool bool) -> string </procedure>
    191 <procedure>(get-disjuncts linkage*) -> string </procedure>
    192 <procedure>(get-links-domains linkage*) -> string </procedure>
    193 <procedure>(get-pp-msgs linkage*) -> string </procedure>
    194 <procedure>(get-senses linkage*) -> string </procedure>
    195 <procedure>(get-violation-name linkage*) -> string </procedure>
    196 <procedure>(link-length linkage* int) -> int </procedure>
    197 <procedure>(link-label linkage* int) -> int </procedure>
    198 <procedure>(link-llabel linkage* int) -> int </procedure>
    199 <procedure>(link-rlabel linkage* int) -> int </procedure>
    200 <procedure>(link-cost linkage*) -> int </procedure>
    201 <procedure>(link-domain-names  linkage* int) -> list </procedure>
    202 <procedure>(num-words linkage*) -> int </procedure>
    203 <procedure>(num-links linkage*) -> int </procedure>
    204 <procedure>(num-domains linkage* int) -> int </procedure>
    205 <procedure>(unused-word-cost linkage*) -> int </procedure>
    206 <procedure>(delete-linkage! linkage*)</procedure>
    207 
    208 == Changelog
    209 
    210 * 1.0 Initial Release
    211 * 1.1 Fixed bug in functions that returned const char**
    212 
    213 == License
    214 
    215 
    216  This program is free software; you can redistribute it and/or modify
    217  it under the terms of the GNU  Lesser General Public License as
    218  published by the Free Software Foundation; either version 2 of
    219  the License, or (at your option) any later version.
    220 
    221 
    222  This program is distributed in the hope that it will be useful,
    223  but WITHOUT ANY WARRANTY; without  even the implied warranty of
    224  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    225  General Public License for more details.
    226 
    227  
    228  You should have received a copy of the GNU General Public License along with this program; if not,
    229  write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     484Parse-options specify the different parameters that are used to parse
     485sentences. Examples of the kinds of things that are controlled by
     486parse-options include maximum parsing time and memory, whether to use
     487null-links, and whether or not to use 'panic' mode. This data structure
     488is passed in to the various parsing and printing routines along with
     489the sentence.
     490
     491
     492Default value for parse-option members are:
     493
     494verbosity                →  0
     495
     496linkage-limit    →  10000
     497
     498min-null-count   â†’  0
     499
     500max-null-count   â†’  0
     501
     502null-block               â†’  1
     503
     504islands-ok           â†’  #f
     505
     506short-length     â†’  6
     507
     508all-short                →  #f
     509
     510display-short    →  #t
     511
     512display-word-subscripts  →  #t
     513
     514display-link-subscripts  →  #t
     515
     516display-walls            →  #f
     517
     518allow-null                       â†’  #t
     519
     520echo-on                  → #f
     521
     522batch-mode               â†’  #f
     523
     524panic-mode               â†’  #f
     525
     526screen-width     â†’  79
     527
     528display-on               â†’  #t
     529
     530display-postscript      →  #f
     531
     532display-bad              →  #f
     533
     534display-links    →  #f
     535
     536
     537==== {{init-opts}}
     538<procedure>(init-opts) → parse-options</procedure>
     539Initilise parse-options to default values
     540
     541==== {{set-max-parse-time!}}
     542<procedure>(set-max-parse-time! parse-options value) → unspecified</procedure>
     543Set maximum parse time
     544; {{parse-options}} :
     545; {{value}} : (number)
     546==== {{set-linkage-limit!}}
     547<procedure>(set-linkage-limit! parse-options linkage-limit) → unspecified</procedure>
     548Set linkage limit
     549; {{parse-options}} :
     550; {{linkage-limit}} : (number)
     551==== {{set-short-length!}}
     552<procedure>(set-short-length! parse-options short-length) → unspecified</procedure>
     553The short_length parameter determines how long the links are allowed to
     554be. The intended use of this is to speed up parsing by not considering
     555very long links for most connectors, since they are very rarely used in
     556a correct parse. An entry for UNLIMITED-CONNECTORS in the dictionary will
     557specify which connectors are exempt from the length limit.
     558; {{parse-options}} :
     559; {{short-length}} : (number)
     560==== {{set-disjunct-cost!}}
     561<procedure>(set-disjunct-cost! parse-options disjunt-cost) → unspecified</procedure>
     562Determines the maximum disjunct cost used during parsing, where the cost
     563of a disjunct is equal to the maximum cost of all of its connectors. The
     564default is that only disjuncts up to a cost of 2.9 are considered.
     565; {{parse-options}} :
     566; {{disjunt-cost}} :
     567==== {{set-min-null-count!}}
     568<procedure>(set-min-null-count! parse-options null-count) → unspecified</procedure>
     569When parsing a sentence, the parser will find all solutions having the
     570minimum number of null links. It carries out its search in the range of null
     571link counts between min_null_count and max_null_count. By default, the minimum
     572and maximum number of null links is 0, so null links are not used.
     573; {{parse-options}} :
     574; {{null-count}} :
     575==== {{set-max-null-count!}}
     576<procedure>(set-max-null-count! parse-options null-count) → unspecified</procedure>
     577When parsing a sentence, the parser will find all solutions having the
     578minimum number of null links. It carries out its search in the range of null
     579link counts between min-null-count and max-null-count. By default, the minimum
     580and maximum number of null links is 0, so null links are not used.
     581; {{parse-options}} :
     582; {{null-count}} :
     583==== {{reset-resources!}}
     584<procedure>(reset-resources! parse-options) → unspecified</procedure>
     585Reset acquired resources
     586; {{parse-options}} :
     587==== {{resources-exhausted?}}
     588<procedure>(resources-exhausted? parse-options) → boolean</procedure>
     589Resources_exhausted means  memory-exhausted? OR timer-expired?
     590; {{parse-options}} :
     591==== {{memory-exhausted?}}
     592<procedure>(memory-exhausted? parse-options) → number</procedure>
     593Checks whether the memory was exhausted during parsing
     594; {{parse-options}} :
     595==== {{timer-expired?}}
     596<procedure>(timer-expired? parse-options) → number</procedure>
     597Checks whether the timer was exceeded during parsing.
     598; {{parse-options}} :
     599==== {{set-islands-ok!}}
     600<procedure>(set-islands-ok! parse-options islands-ok?) → unspecified</procedure>
     601This option determines whether or not 'islands' of links are allowed.
     602; {{parse-options}} :
     603; {{islands-ok?}} : A boolean to indicate whether islands are allowed
     604==== {{set-verbosity!}}
     605<procedure>(set-verbosity! parse-options verbosity-level) → unspecified</procedure>
     606Sets/gets the level of description printed to stderr/stdout about the
     607parsing process.
     608; {{parse-options}} :
     609; {{verbosity-level}} :
     610==== {{get-verbosity}}
     611<procedure>(get-verbosity parse-options) → number</procedure>
     612Get the verbosity level
     613; {{parse-options}} :
     614==== {{delete-parse-options!}}
     615<procedure>(delete-parse-options! parse-options) → number</procedure>
     616Delete a parse-option object
     617; {{parse-options}} :
     618=== License
     619This program is free software; you can redistribute it and/or modify
     620it under the terms of the GNU  Lesser General Public License as
     621published by the Free Software Foundation; either version 2 of
     622the License, or (at your option) any later version.
     623
     624This program is distributed in the hope that it will be useful, but WITHOUT ANY
     625WARRANTY; without  even the implied warranty of MERCHANTABILITY or FITNESS FOR
     626A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     627
     628You should have received a copy of the GNU General Public License along with
     629this program; if not, write to the Free Software Foundation, Inc., 59 Temple
     630Place, Suite 330, Boston, MA  02111-1307 USA
     631
     632
     633=== About this egg
     634
     635==== Author
     636
     637[[/users/djireland|David Ireland]]
     638
     639
     640
     641==== Versions
     642; 1.3 :
     643==== Colophon
     644
     645Documented by [[/egg/hahn|hahn]].
Note: See TracChangeset for help on using the changeset viewer.