synset 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -39
- package/dist/cli.cjs +534 -382
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +542 -383
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +301 -166
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -7
- package/dist/index.d.ts +26 -7
- package/dist/index.js +307 -167
- package/dist/index.js.map +1 -1
- package/dist/schema.sql +22 -0
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -1,19 +1,50 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/synset)
|
|
2
|
+
|
|
1
3
|
# synset
|
|
2
4
|
|
|
3
5
|
WordNet dictionary parser with Zod validation, query utilities, and CLI.
|
|
4
6
|
|
|
5
|
-
##
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
### CLI
|
|
6
10
|
|
|
7
11
|
```bash
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
# Run without installing
|
|
13
|
+
bunx synset define dog
|
|
14
|
+
|
|
15
|
+
# List synonyms
|
|
16
|
+
bunx synset synonyms happy
|
|
17
|
+
|
|
18
|
+
# Show hypernyms (more general terms)
|
|
19
|
+
bunx synset hypernyms dog
|
|
20
|
+
|
|
21
|
+
# Show all relations
|
|
22
|
+
bunx synset related computer
|
|
23
|
+
|
|
24
|
+
# Pre-download WordNet data
|
|
25
|
+
bunx synset fetch
|
|
26
|
+
|
|
27
|
+
# Export to SQLite database
|
|
28
|
+
bunx synset export-sqlite dictionary.db
|
|
29
|
+
|
|
30
|
+
# Use local file instead of cache
|
|
31
|
+
bunx synset define dog --file ./path/to/english-wordnet-{YEAR}.xml
|
|
11
32
|
```
|
|
12
33
|
|
|
13
|
-
|
|
34
|
+
> Or install globally:
|
|
35
|
+
> ```bash
|
|
36
|
+
> bun install -g synset
|
|
37
|
+
> synset define dog
|
|
38
|
+
> ```
|
|
14
39
|
|
|
15
40
|
### Library
|
|
16
41
|
|
|
42
|
+
```bash
|
|
43
|
+
npm install synset
|
|
44
|
+
# or
|
|
45
|
+
bun add synset
|
|
46
|
+
```
|
|
47
|
+
|
|
17
48
|
```ts
|
|
18
49
|
import {
|
|
19
50
|
fetchWordNet,
|
|
@@ -32,9 +63,6 @@ console.log(`Loaded WordNet ${version}`)
|
|
|
32
63
|
// Or load from local file
|
|
33
64
|
const lexicon = await loadWordNet('./path/to/english-wordnet-{YEAR}.xml')
|
|
34
65
|
|
|
35
|
-
// Or request specific version
|
|
36
|
-
const { lexicon } = await fetchWordNet({ version: '2024' })
|
|
37
|
-
|
|
38
66
|
// Build index for fast lookups
|
|
39
67
|
const index = buildIndex(lexicon)
|
|
40
68
|
|
|
@@ -52,45 +80,32 @@ findSynsets(index, 'bank')
|
|
|
52
80
|
// [Synset for "financial institution", Synset for "river bank", ...]
|
|
53
81
|
```
|
|
54
82
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
# Show definitions
|
|
59
|
-
synset define dog
|
|
60
|
-
|
|
61
|
-
# List synonyms
|
|
62
|
-
synset synonyms happy
|
|
63
|
-
|
|
64
|
-
# Show hypernyms (more general terms)
|
|
65
|
-
synset hypernyms dog
|
|
66
|
-
|
|
67
|
-
# Show all relations
|
|
68
|
-
synset related computer
|
|
69
|
-
|
|
70
|
-
# Pre-download WordNet data
|
|
71
|
-
synset fetch
|
|
72
|
-
|
|
73
|
-
# Use local file instead of cache
|
|
74
|
-
synset define dog --file ./path/to/english-wordnet-{YEAR}.xml
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Exports
|
|
83
|
+
#### SQLite Export
|
|
78
84
|
|
|
79
85
|
```ts
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
import { exportToSQLite } from 'synset'
|
|
87
|
+
|
|
88
|
+
// Export to SQLite (requires Bun runtime)
|
|
89
|
+
exportToSQLite(lexicon, 'dictionary.db', {
|
|
90
|
+
onProgress: ({ phase, current, total }) => {
|
|
91
|
+
console.log(`${phase}: ${current}/${total}`)
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
```
|
|
85
95
|
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
Schema:
|
|
97
|
+
```
|
|
98
|
+
words(id, word, word_display)
|
|
99
|
+
synsets(id, pos, definition)
|
|
100
|
+
word_synsets(word_id, synset_id)
|
|
88
101
|
```
|
|
89
102
|
|
|
90
103
|
## Runtime
|
|
91
104
|
|
|
92
105
|
- **Bun**: Full support (recommended)
|
|
93
|
-
- **Node.js 18+**:
|
|
106
|
+
- **Node.js 18+**: Full support
|
|
107
|
+
|
|
108
|
+
> **Note:** SQLite export (`exportToSQLite`, `export-sqlite`) requires Bun (uses `bun:sqlite`).
|
|
94
109
|
|
|
95
110
|
## Development
|
|
96
111
|
|