@@ -65,7 +65,7 @@ For Node.js REPL:
6565const fuzzyViz = await import (" @thi.ng/fuzzy-viz" );
6666```
6767
68- Package sizes (brotli'd, pre-treeshake): ESM: 1.01 KB
68+ Package sizes (brotli'd, pre-treeshake): ESM: 1.00 KB
6969
7070## Dependencies
7171
@@ -88,19 +88,18 @@ variable](https://github.com/thi-ng/umbrella/tree/develop/packages/fuzzy#linguis
8888
8989![ fuzzy set visualization of the example l-var] ( https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/fuzzy/temperature-lvar-2.svg )
9090
91- ``` ts
91+ ``` ts tangle:export/readme-svg.ts
92+ import { invSigmoid , sigmoid , trapezoid , variable } from " @thi.ng/fuzzy" ;
9293import { varToSvg } from " @thi.ng/fuzzy-viz" ;
94+ import { writeFileSync } from " fs" ;
9395
9496// temperature sets (in celsius)
95- const temp = variable (
96- [- 20 , 40 ],
97- {
98- freezing: invSigmoid (0 , 2 ),
99- cold: trapezoid (- 1 , 2 , 16 , 20 ),
100- warm: trapezoid (15 , 20 , 30 , 34 ),
101- hot: sigmoid (32 , 2 )
102- }
103- );
97+ const temp = variable ([- 20 , 40 ], {
98+ freezing: invSigmoid (0 , 2 ),
99+ cold: trapezoid (- 1 , 2 , 16 , 20 ),
100+ warm: trapezoid (15 , 20 , 30 , 34 ),
101+ hot: sigmoid (32 , 2 ),
102+ });
104103
105104// generate & write SVG file
106105writeFileSync (" temperature.svg" , varToSvg (temp , { samples: 200 }));
@@ -130,10 +129,13 @@ accumulate. If re-using the instrumented strategy for multiple `defuzz()`
130129invocations, it's highly recommended to clear any previous results using
131130` .clear() ` .
132131
133- ``` ts
132+ ``` ts tangle:export/readme-ascii.ts
133+ import { centroidStrategy , gaussian } from " @thi.ng/fuzzy" ;
134+ import { fuzzySetToAscii , instrumentStrategy } from " @thi.ng/fuzzy-viz" ;
135+
134136const strategy = instrumentStrategy (
135- cogStrategy ({ samples: 1000 }),
136- fuzzySetToAscii ({ width: 40 , height: 8 })
137+ centroidStrategy ({ samples: 1000 }),
138+ fuzzySetToAscii ({ width: 40 , height: 8 })
137139);
138140
139141// apply strategy as normal (well, usually done via defuzz())
0 commit comments