|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-May-2022 | - |
| dict-common/ | H | 03-May-2022 | - | 4,738 | 3,151 |
| dict-file/ | H | 03-May-2022 | - | 3,146 | 2,083 |
| dict-sql/ | H | 03-May-2022 | - | 727 | 457 |
| linkage/ | H | 03-May-2022 | - | 2,017 | 1,243 |
| minisat/ | H | 03-May-2022 | - | 4,913 | 3,200 |
| parse/ | H | 03-May-2022 | - | 5,864 | 3,775 |
| post-process/ | H | 03-May-2022 | - | 6,353 | 4,383 |
| prepare/ | H | 03-May-2022 | - | 1,153 | 749 |
| print/ | H | 03-May-2022 | - | 2,459 | 1,790 |
| sat-solver/ | H | 03-May-2022 | - | 4,769 | 3,425 |
| tokenize/ | H | 03-May-2022 | - | 6,063 | 3,879 |
| Makefile.am | H A D | 03-May-2022 | 6.8 KiB | 221 | 186 |
| Makefile.in | H A D | 03-May-2022 | 57 KiB | 1,518 | 1,395 |
| README.md | H A D | 03-May-2022 | 5.6 KiB | 147 | 111 |
| api-structures.h | H A D | 03-May-2022 | 7.3 KiB | 183 | 98 |
| api-types.h | H A D | 03-May-2022 | 1.9 KiB | 48 | 21 |
| api.c | H A D | 03-May-2022 | 19 KiB | 766 | 555 |
| connectors.c | H A D | 03-May-2022 | 14.6 KiB | 561 | 389 |
| connectors.h | H A D | 03-May-2022 | 11.3 KiB | 345 | 195 |
| const-prime.h | H A D | 03-May-2022 | 1.7 KiB | 67 | 47 |
| disjunct-utils.c | H A D | 03-May-2022 | 28.8 KiB | 956 | 540 |
| disjunct-utils.h | H A D | 03-May-2022 | 5.6 KiB | 149 | 90 |
| error.c | H A D | 03-May-2022 | 10.9 KiB | 410 | 251 |
| error.h | H A D | 03-May-2022 | 4.5 KiB | 109 | 42 |
| externs.h | H A D | 03-May-2022 | 1.1 KiB | 20 | 6 |
| lg_assert.h | H A D | 03-May-2022 | 2 KiB | 49 | 29 |
| link-features.h | H A D | 03-May-2022 | 2.6 KiB | 55 | 43 |
| link-features.h.in | H A D | 03-May-2022 | 1.5 KiB | 55 | 45 |
| link-grammar.def | H A D | 03-May-2022 | 3.1 KiB | 123 | 122 |
| link-includes.h | H A D | 03-May-2022 | 14.9 KiB | 430 | 304 |
| memory-pool.c | H A D | 03-May-2022 | 8.7 KiB | 310 | 209 |
| memory-pool.h | H A D | 03-May-2022 | 4 KiB | 105 | 66 |
| resources.c | H A D | 03-May-2022 | 5.4 KiB | 203 | 148 |
| resources.h | H A D | 03-May-2022 | 1.4 KiB | 29 | 14 |
| string-id.c | H A D | 03-May-2022 | 5.7 KiB | 217 | 155 |
| string-id.h | H A D | 03-May-2022 | 2.4 KiB | 61 | 37 |
| string-set.c | H A D | 03-May-2022 | 6.7 KiB | 242 | 159 |
| string-set.h | H A D | 03-May-2022 | 3.2 KiB | 82 | 47 |
| tracon-set.c | H A D | 03-May-2022 | 7 KiB | 240 | 154 |
| tracon-set.h | H A D | 03-May-2022 | 2.1 KiB | 53 | 32 |
| utilities.c | H A D | 03-May-2022 | 20.7 KiB | 828 | 554 |
| utilities.h | H A D | 03-May-2022 | 15.1 KiB | 521 | 351 |
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