• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

dict-common/H03-May-2022-4,7383,151

dict-file/H03-May-2022-3,1462,083

dict-sql/H03-May-2022-727457

linkage/H03-May-2022-2,0171,243

minisat/H03-May-2022-4,9133,200

parse/H03-May-2022-5,8643,775

post-process/H03-May-2022-6,3534,383

prepare/H03-May-2022-1,153749

print/H03-May-2022-2,4591,790

sat-solver/H03-May-2022-4,7693,425

tokenize/H03-May-2022-6,0633,879

Makefile.amH A D03-May-20226.8 KiB221186

Makefile.inH A D03-May-202257 KiB1,5181,395

README.mdH A D03-May-20225.6 KiB147111

api-structures.hH A D03-May-20227.3 KiB18398

api-types.hH A D03-May-20221.9 KiB4821

api.cH A D03-May-202219 KiB766555

connectors.cH A D03-May-202214.6 KiB561389

connectors.hH A D03-May-202211.3 KiB345195

const-prime.hH A D03-May-20221.7 KiB6747

disjunct-utils.cH A D03-May-202228.8 KiB956540

disjunct-utils.hH A D03-May-20225.6 KiB14990

error.cH A D03-May-202210.9 KiB410251

error.hH A D03-May-20224.5 KiB10942

externs.hH A D03-May-20221.1 KiB206

lg_assert.hH A D03-May-20222 KiB4929

link-features.hH A D03-May-20222.6 KiB5543

link-features.h.inH A D03-May-20221.5 KiB5545

link-grammar.defH A D03-May-20223.1 KiB123122

link-includes.hH A D03-May-202214.9 KiB430304

memory-pool.cH A D03-May-20228.7 KiB310209

memory-pool.hH A D03-May-20224 KiB10566

resources.cH A D03-May-20225.4 KiB203148

resources.hH A D03-May-20221.4 KiB2914

string-id.cH A D03-May-20225.7 KiB217155

string-id.hH A D03-May-20222.4 KiB6137

string-set.cH A D03-May-20226.7 KiB242159

string-set.hH A D03-May-20223.2 KiB8247

tracon-set.cH A D03-May-20227 KiB240154

tracon-set.hH A D03-May-20222.1 KiB5332

utilities.cH A D03-May-202220.7 KiB828554

utilities.hH A D03-May-202215.1 KiB521351

README.md

1
2Directories
3===========
4Listed in rough processing order.
5
6 * dict-common  - generic dictionary-handling code.
7 * dict-file    - read dictionaries from files.
8 * dict-sql     - read dictionaries from an SQL DB
9                  (unfinished, under development!).
10
11 * tokenize     - Convert sentence strings into word sequences.
12                  Actually, into a word-graph of possible words.
13
14 * prepare      - After tokenization, prepare sentence for parsing.
15
16 * parse        - Classic Sleator/Temperley/Lafferty parser.
17
18 * minisat      - Copy of the mini-SAT Boolean-SAT solver.
19 * sat-solver   - Alternate parser, using boolean-SAT.
20
21 * linkage      - Construction and analysis of linkages from parsing.
22
23 * post-process - Constraint rules applied after parsing.
24                  Also, rules for constituent-tree construction.
25
26 * print        - functions that convert parses into
27                  human-readable strings and printed output.
28
29
30Version 5.3.14 - Improved error notification facility
31=====================================================
32
33This code is still "experimental", so it's API may be changed.
34
35It is intended to be mostly compatible. It supports multi-threading -
36all of its operations are local per-thread.
37A visible change is that the first parameter of `prt_error()` should now end
38with a newline in order to actually issue a message. However, its previous
39auto-issuing of a newline was not documented.
40
41Features:
42---------
43- Ability to intercept error messages (when required). This allows printing
44them not only to stdout/stderr, but to any other stream (like logging)
45or place (like a GUI window). This also allows to reformat the message.
46
47- Possibility to print a message in parts and still have it printed as one
48 complete message. The API for that is natural - messages are gathered
49until a newline (if a message ends with `\n\\` this is an embedded
50newline). The severity level of the last part, if exists, is used for the
51whole message.
52
53- New _severity levels_:
54  * **Trace** (for `lgdebug()`).
55  * **Debug** (for other debug messages).
56  * **None** (for plain messages that need to use the error facility).
57
58C API:
59------
601)  `lg_error_handler lg_error_set_handler(lg_error_handler, void *data);`
61
62Set an error handler function. Return the previous one.
63On first call it returns the default handler function, that is
64pre-installed on program start.
65If the error handler is set to `NULL`, the messages are just queued,
66and can be retrieved by `lg_error_printall()` (see (4) below).
67
68For the default error handler, if data is not NULL, it is an
69`(int *)` severity_level. Messages with <= this level are printed to stdout.
70The default is to print Debug and lower to stdout.
71For custom error handler it can be of course a more complex user-data.
72
732)  `const void *lg_error_set_handler_data(void * data);`
74
75Return the current error handler user-data.
76(This function is useful mainly for implementing correct language
77bindings, which may need to free previously-allocated user-data).
78
793)  `char *lg_error_formatmsg(lg_errinfo *lge);`
80
81Format the argument message.
82It adds `link-grammar` and severity.
83The `lg_errinfo` struct is part of the API.
84
854)  `int lg_error_printall(lg_error_handler, void *data);`
86
87Print all the queued error messages and clear the queue.
88Return the number of messages.
89
905)  `int lg_error_clearall(void);`
91Clear the queue of error messages.
92Return the number of messages.
93
946)  `int prt_error(const char *fmt, ...);`
95Previously it was a void function, but now it returns an `int` (always 0) so
96it can be used in complex macros (which make it necessary to use the comma
97operator).
98
99`prt_error()` still gets the severity label as a message prefix.
100The list of error severities is defined as part of the API, and the
101prefix that is used here is without the `lg_` part of the corresponding
102enums.  The default severity is **None"**, i.e. a plain message.
103(However, the enum severity code can be specified with the internal API
104`err_msg()`. When both are specified, the label takes precedence. All of
105these ways have their use in the code.)
106
107Issuing a message in parts is supported. The message is collected until
108its end and issued as one complete message. Issuing an embedded newline is
109supported. In addition to a newline in a middle of string, which doesn't
110terminate the message, and ending `\n\\` is a embedded newline.
111This allows, for example, constructing a single message using a loop or
112conditionals.
113
1147)  `bool lg_error_flush(void);`
115If a partial error message is buffered, flush it by adding a "\n" to it.
116If no error message is buffered - do nothing.
117Return **true** iff there was a message to flush.
118
119See [link-includes.h](link-includes.h) for the definition of
120severity levels and the `lg_errinfo` structure.
121
122Notes:
123------
1241.  `lgdebug()` (used internally to issue debug or informational messages at
125a given verbosity level) now usually uses by default the new severity level
126`lg_Trace` but can instead use other levels (currently it sometimes uses
127`lg_Debug` or `lg_Info)`.
128
1292.  Some messages from the library may still use `printf()`, and the
130intention is to convert them too to use the new error facility.
131
132Language bindings:
133------------------
134A complete Python binding is provided under `class LG_Error`:
135```
136LG_Error.set_handler()
137LG_Error.printall()
138LG_Error.clearall()
139LG_Error.message()     # prt_error()
140errinfo.formatmsg()    # errinfo is the first argument of the error handler
141errinfo.severity, errinfo.severity_label, errinfo.text # lg_errinfo fields
142```
143
144`class LG_Error` is also used as a general exception.
145See [tests.py](../bindings/python-examples/tests.py) for usage of all of these
146bindings.
147