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 CHANGED
@@ -1,19 +1,50 @@
1
+ [![npm version](https://img.shields.io/npm/v/synset.svg)](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
- ## Install
7
+ ## Usage
8
+
9
+ ### CLI
6
10
 
7
11
  ```bash
8
- npm install synset
9
- # or
10
- bun add synset
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
- ## Usage
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
- ### CLI
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
- // Zod schemas (runtime validation)
81
- import { Lexicon, Synset, Sense, LexicalEntry } from 'synset'
82
-
83
- // TypeScript types
84
- import type { LexiconType, SynsetType, SenseType } from 'synset'
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
- // Human-readable labels
87
- import { PartsOfSpeechLabels, SynsetRelationLabels } from 'synset'
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+**: Supported for remote fetching. Local file parsing requires Bun due to `file://` URL fetch limitations.
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