You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/manual/parsers.md
+5-40Lines changed: 5 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,10 +20,10 @@ Parsers are obtained by name with `get_parser()`:
20
20
```python
21
21
from hyperbase import get_parser
22
22
23
-
parser = get_parser("alphabeta", language="en")
23
+
parser = get_parser("alphabeta", lang="en")
24
24
```
25
25
26
-
The keyword arguments are forwarded to the parser constructor. Each parser plugin defines its own parameters -- for example, `alphabeta` takes a `language` code, while `generative` accepts `model_path`, `device`, `max_length`, and others.
26
+
The keyword arguments are forwarded to the parser constructor. Each parser plugin defines its own parameters -- for example, `alphabeta` takes a `lang` code, while `generative` accepts `model_path`, `device`, `max_length`, and others. Run `hyperbase repl --parser <name> --help` (or `hyperbase read --parser <name> --help`) to see the full set of CLI flags injected by the active plugin.
27
27
28
28
To see which parsers are installed:
29
29
@@ -125,42 +125,7 @@ This is what `read_source_to_jsonl()` uses internally -- each line in the output
125
125
126
126
## Quality checking
127
127
128
-
The `hyperbase.parsers.correctness` module provides functions to assess the quality of a parse result.
129
-
130
-
### Badness check
131
-
132
-
`badness_check()` runs a comprehensive quality check on a parsed edge, combining structural validation with token-to-atom matching:
133
-
134
-
```python
135
-
from hyperbase.parsers.correctness import badness_check
The function returns a dictionary mapping edge fragments (or the string `'token-matching'`) to lists of `(code, message, severity)` tuples. An empty dictionary means no errors were found.
147
-
148
-
The checks include:
149
-
150
-
-**Structural correctness** -- validates the hyperedge against the SH specification (via `Hyperedge.check_correctness()`).
151
-
-**Argument role validation** -- checks that argument roles are drawn from the valid set (`m`, `s`, `p`, `a`, `o`, `i`, `x`, `t`, `j`, `r`, `c`) and that roles like `s`, `p`, `o` are not duplicated.
152
-
-**Junction consistency** -- verifies that junction arguments are consistently typed (all relations or all concepts).
153
-
-**Token matching** -- ensures that every token in the original sentence maps to an atom root in the edge, and vice versa. Handles multi-token atoms, contractions and other non-trivial correspondences.
154
-
155
-
### Structural quality only
156
-
157
-
For a lighter check that skips token matching:
158
-
159
-
```python
160
-
from hyperbase.parsers.correctness import check_structural_quality
161
-
162
-
errors = check_structural_quality(result.edge)
163
-
```
128
+
Badness/correctness checking lives in the parser plugin that needs it. The generative parser ships [`hyperbase_parser_gen.correctness.badness_check`](https://github.com/telmomenezes/hyperbase-parser-gen) for combined structural + token-matching validation; see that package's docs for usage.
164
129
165
130
## CLI
166
131
@@ -177,7 +142,7 @@ Shows all installed parser plugins and their entry point values.
177
142
The REPL lets you parse sentences interactively:
178
143
179
144
```bash
180
-
hyperbase repl --parser alphabeta --language en
145
+
hyperbase repl --parser alphabeta --lang en
181
146
```
182
147
183
148
Inside the REPL, type a sentence to parse it. Use `/help` to see available commands, `/settings` to view current configuration, and `/set` to change settings on the fly (e.g. `/set parser generative`). The REPL caches parser instances, so switching between parsers is fast after the first load.
@@ -186,7 +151,7 @@ Inside the REPL, type a sentence to parse it. Use `/help` to see available comma
186
151
187
152
```bash
188
153
# Parse a file to JSONL
189
-
hyperbase read article.txt -o output.jsonl --parser alphabeta --language en
154
+
hyperbase read article.txt -o output.jsonl --parser alphabeta --lang en
0 commit comments