@higher.archi/boe 1.0.25 → 1.0.27

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/dist/index.js CHANGED
@@ -29,9 +29,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
29
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.UtilityStrategy = exports.SEMANTIC_WEIGHTS = exports.constraintStrategy = exports.compileConstraintRuleSet = exports.ConstraintStrategy = exports.stateMachineStrategy = exports.compileStateMachineDefinition = exports.compileStateMachine = exports.StateMachineStrategy = exports.monteCarloStrategy = exports.compileMonteCarloRuleSet = exports.MonteCarloStrategy = exports.SEMANTIC_LIKELIHOODS = exports.parseLikelihood = exports.bayesianStrategy = exports.compileBayesianRule = exports.compileBayesianRuleSet = exports.BayesianStrategy = exports.autoAdjustCoverage = exports.analyzeCoverage = exports.compileFuzzyVariable = exports.fuzzyStrategy = exports.compileFuzzyRuleSet = exports.FuzzyStrategy = exports.sequentialStrategy = exports.compileSequentialRuleSet = exports.SequentialStrategy = exports.createScoreFunction = exports.scoringStrategy = exports.compileScoringRuleSet = exports.ScoringStrategy = exports.backwardStrategy = exports.compileBackwardRuleSet = exports.BackwardChainingStrategy = exports.forwardStrategy = exports.compileForwardRule = exports.compileForwardRuleSet = exports.ForwardChainingStrategy = exports.EnsembleEngine = exports.PricingEngine = exports.UtilityEngine = exports.ConstraintEngine = exports.StateMachineEngine = exports.MonteCarloEngine = exports.BayesianEngine = exports.FuzzyEngine = exports.SequentialEngine = exports.ScoringEngine = exports.BackwardEngine = exports.ForwardEngine = void 0;
33
- exports.predictionStrategy = exports.compilePredictionRuleSet = exports.PredictionExecutor = exports.PredictionEngine = exports.resolveMovement = exports.resolvePercentileLabel = exports.isKFactorPreset = exports.K_FACTOR_VALUES = exports.rankingStrategy = exports.compileRankingRuleSet = exports.RankingExecutor = exports.RankingEngine = exports.scoringMember = exports.expertMember = exports.monteCarloMember = exports.fuzzyMember = exports.bayesianMember = exports.summarizeEnsemble = exports.ensembleStrategy = exports.compileEnsembleRuleSet = exports.EnsembleStrategy = exports.getCurrencyInfo = exports.CURRENCIES = exports.applyMinMax = exports.calculateDiscount = exports.round = exports.formatPercent = exports.formatNumber = exports.formatCurrency = exports.calculateVolume = exports.calculateGraduated = exports.calculateFlat = exports.pricingEngine = exports.pricingStrategy = exports.compilePricingRule = exports.compilePricingRuleSet = exports.PricingStrategy = exports.buildAvailableRefs = exports.hasInterpolation = exports.interpolate = exports.compileTemplate = exports.expertStrategy = exports.compileExpertRuleSet = exports.ExpertStrategy = exports.ExpertEngine = exports.compileDefeasibleRuleSet = exports.DefeasibleEngine = exports.utilityStrategy = exports.compileUtilityRule = exports.compileUtilityRuleSet = void 0;
34
- exports.resolveDecayTimestamp = exports.calculateDecayMultiplier = exports.RuntimeError = exports.CompilationError = exports.BOEError = exports.cosineSimilarity = exports.caverphone2 = exports.nysiis = exports.soundex = exports.resolveTrendDirection = exports.resolveConfidenceBracket = exports.isHorizonPreset = exports.isSmoothingPreset = exports.HORIZON_PRESET_VALUES = exports.SMOOTHING_PRESET_VALUES = void 0;
32
+ exports.SEMANTIC_WEIGHTS = exports.constraintStrategy = exports.compileConstraintRuleSet = exports.ConstraintStrategy = exports.stateMachineStrategy = exports.compileStateMachineDefinition = exports.compileStateMachine = exports.StateMachineStrategy = exports.monteCarloStrategy = exports.compileMonteCarloRuleSet = exports.MonteCarloStrategy = exports.SEMANTIC_LIKELIHOODS = exports.parseLikelihood = exports.bayesianStrategy = exports.compileBayesianRule = exports.compileBayesianRuleSet = exports.BayesianStrategy = exports.autoAdjustCoverage = exports.analyzeCoverage = exports.compileFuzzyVariable = exports.fuzzyStrategy = exports.compileFuzzyRuleSet = exports.FuzzyStrategy = exports.sequentialStrategy = exports.compileSequentialRuleSet = exports.SequentialStrategy = exports.createScoreFunction = exports.scoringStrategy = exports.compileScoringRuleSet = exports.ScoringStrategy = exports.backwardStrategy = exports.compileBackwardRuleSet = exports.BackwardChainingStrategy = exports.forwardStrategy = exports.compileForwardRule = exports.compileForwardRuleSet = exports.ForwardChainingStrategy = exports.SentimentEngine = exports.EnsembleEngine = exports.PricingEngine = exports.UtilityEngine = exports.ConstraintEngine = exports.StateMachineEngine = exports.MonteCarloEngine = exports.BayesianEngine = exports.FuzzyEngine = exports.SequentialEngine = exports.ScoringEngine = exports.BackwardEngine = exports.ForwardEngine = void 0;
33
+ exports.compilePredictionRuleSet = exports.PredictionExecutor = exports.PredictionEngine = exports.resolveMovement = exports.resolvePercentileLabel = exports.isKFactorPreset = exports.K_FACTOR_VALUES = exports.rankingStrategy = exports.compileRankingRuleSet = exports.RankingExecutor = exports.RankingEngine = exports.scoringMember = exports.expertMember = exports.monteCarloMember = exports.fuzzyMember = exports.bayesianMember = exports.summarizeEnsemble = exports.ensembleStrategy = exports.compileEnsembleRuleSet = exports.EnsembleStrategy = exports.getCurrencyInfo = exports.CURRENCIES = exports.applyMinMax = exports.calculateDiscount = exports.round = exports.formatPercent = exports.formatNumber = exports.formatCurrency = exports.calculateVolume = exports.calculateGraduated = exports.calculateFlat = exports.pricingEngine = exports.pricingStrategy = exports.compilePricingRule = exports.compilePricingRuleSet = exports.PricingStrategy = exports.buildAvailableRefs = exports.hasInterpolation = exports.interpolate = exports.compileTemplate = exports.expertStrategy = exports.compileExpertRuleSet = exports.ExpertStrategy = exports.ExpertEngine = exports.compileDefeasibleRuleSet = exports.DefeasibleEngine = exports.utilityStrategy = exports.compileUtilityRule = exports.compileUtilityRuleSet = exports.UtilityStrategy = void 0;
34
+ exports.resolveDecayTimestamp = exports.calculateDecayMultiplier = exports.RuntimeError = exports.CompilationError = exports.BOEError = exports.cosineSimilarity = exports.caverphone2 = exports.nysiis = exports.soundex = exports.resolveSentimentLabel = exports.SENTIMENT_DEFAULTS = exports.sentimentStrategy = exports.compileSentimentRuleSet = exports.SentimentExecutor = exports.resolveTrendDirection = exports.resolveConfidenceBracket = exports.isHorizonPreset = exports.isSmoothingPreset = exports.HORIZON_PRESET_VALUES = exports.SMOOTHING_PRESET_VALUES = exports.predictionStrategy = void 0;
35
35
  // ========================================
36
36
  // Engines
37
37
  // ========================================
@@ -60,6 +60,8 @@ var pricing_1 = require("./engines/pricing");
60
60
  Object.defineProperty(exports, "PricingEngine", { enumerable: true, get: function () { return pricing_1.PricingEngine; } });
61
61
  var ensemble_1 = require("./engines/ensemble");
62
62
  Object.defineProperty(exports, "EnsembleEngine", { enumerable: true, get: function () { return ensemble_1.EnsembleEngine; } });
63
+ var sentiment_1 = require("./engines/sentiment");
64
+ Object.defineProperty(exports, "SentimentEngine", { enumerable: true, get: function () { return sentiment_1.SentimentEngine; } });
63
65
  // ========================================
64
66
  // Core Types & Utilities
65
67
  // ========================================
@@ -198,6 +200,13 @@ Object.defineProperty(exports, "isSmoothingPreset", { enumerable: true, get: fun
198
200
  Object.defineProperty(exports, "isHorizonPreset", { enumerable: true, get: function () { return prediction_1.isHorizonPreset; } });
199
201
  Object.defineProperty(exports, "resolveConfidenceBracket", { enumerable: true, get: function () { return prediction_1.resolveConfidenceBracket; } });
200
202
  Object.defineProperty(exports, "resolveTrendDirection", { enumerable: true, get: function () { return prediction_1.resolveTrendDirection; } });
203
+ // Sentiment
204
+ var sentiment_2 = require("./engines/sentiment");
205
+ Object.defineProperty(exports, "SentimentExecutor", { enumerable: true, get: function () { return sentiment_2.SentimentExecutor; } });
206
+ Object.defineProperty(exports, "compileSentimentRuleSet", { enumerable: true, get: function () { return sentiment_2.compileSentimentRuleSet; } });
207
+ Object.defineProperty(exports, "sentimentStrategy", { enumerable: true, get: function () { return sentiment_2.sentimentStrategy; } });
208
+ Object.defineProperty(exports, "SENTIMENT_DEFAULTS", { enumerable: true, get: function () { return sentiment_2.SENTIMENT_DEFAULTS; } });
209
+ Object.defineProperty(exports, "resolveSentimentLabel", { enumerable: true, get: function () { return sentiment_2.resolveSentimentLabel; } });
201
210
  // ========================================
202
211
  // Utility Functions (from old modules, re-exported for convenience)
203
212
  // ========================================
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;AAEH,2CAA2C;AAC3C,UAAU;AACV,2CAA2C;AAE3C,iEAAiE;AACjE,6CAAkD;AAAzC,wGAAA,aAAa,OAAA;AACtB,+CAAoD;AAA3C,0GAAA,cAAc,OAAA;AACvB,6CAAkD;AAAzC,wGAAA,aAAa,OAAA;AACtB,mDAAwD;AAA/C,8GAAA,gBAAgB,OAAA;AACzB,yCAA8C;AAArC,oGAAA,WAAW,OAAA;AACpB,+CAAoD;AAA3C,0GAAA,cAAc,OAAA;AACvB,qDAAyD;AAAhD,+GAAA,gBAAgB,OAAA;AACzB,yDAA6D;AAApD,mHAAA,kBAAkB,OAAA;AAC3B,mDAAwD;AAA/C,8GAAA,gBAAgB,OAAA;AACzB,6CAAkD;AAAzC,wGAAA,aAAa,OAAA;AACtB,6CAAkD;AAAzC,wGAAA,aAAa,OAAA;AACtB,+CAAoD;AAA3C,0GAAA,cAAc,OAAA;AAEvB,2CAA2C;AAC3C,yBAAyB;AACzB,2CAA2C;AAE3C,yCAAuB;AAEvB,2CAA2C;AAC3C,UAAU;AACV,2CAA2C;AAE3C,mBAAmB;AACnB,6CAK2B;AAJzB,kHAAA,uBAAuB,OAAA;AACvB,gHAAA,qBAAqB,OAAA;AACrB,6GAAA,kBAAkB,OAAA;AAClB,0GAAA,eAAe,OAAA;AAcjB,oBAAoB;AACpB,+CAI4B;AAH1B,oHAAA,wBAAwB,OAAA;AACxB,kHAAA,sBAAsB,OAAA;AACtB,4GAAA,gBAAgB,OAAA;AAalB,UAAU;AACV,6CAK2B;AAJzB,0GAAA,eAAe,OAAA;AACf,gHAAA,qBAAqB,OAAA;AACrB,0GAAA,e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AE,mGAAA,MAAM,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAEvD,uDAAuD;AACvD,wCAAyE;AAAhE,kGAAA,QAAQ,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAAE,sGAAA,YAAY,OAAA;AAGjD,yDAAyD;AACzD,iDAGiC;AAF/B,iHAAA,wBAAwB,OAAA;AACxB,8GAAA,qBAAqB,OAAA;AASvB,2CAA2C;AAC3C,wCAAwC;AACxC,2CAA2C;AAE3C,2CAAyB;AAEzB,2CAA2C;AAC3C,iDAAiD;AACjD,2CAA2C;AAE3C,8CAA4B;AAE5B,2CAA2C;AAC3C,uCAAuC;AACvC,2CAA2C;AAE3C,4CAA0B;AAE1B,2CAA2C;AAC3C,8CAA8C;AAC9C,2CAA2C;AAE3C,8CAA4B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@higher.archi/boe",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "A multi-strategy rule engine supporting forward chaining, backward chaining, scoring, sequential, fuzzy logic, and Bayesian inference",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Sentiment Engine Compiler
3
+ *
4
+ * Validates sentiment rulesets, normalizes lexicon keys to lowercase,
5
+ * and resolves config defaults.
6
+ */
7
+
8
+ import { CompilationError } from '../../core/errors';
9
+
10
+ import type {
11
+ SentimentRuleSet,
12
+ CompiledSentimentRuleSet,
13
+ CompiledSentimentLexicon,
14
+ CompiledTokenLevelSentimentRuleSet,
15
+ CompiledDocumentLevelSentimentRuleSet,
16
+ CompiledAspectBasedSentimentRuleSet
17
+ } from './types';
18
+ import { SENTIMENT_DEFAULTS } from './types';
19
+
20
+ /**
21
+ * Compile and validate a sentiment ruleset.
22
+ */
23
+ export function compileSentimentRuleSet(
24
+ ruleSet: SentimentRuleSet
25
+ ): CompiledSentimentRuleSet {
26
+ if (!ruleSet.id) {
27
+ throw new CompilationError('Sentiment ruleset requires an id');
28
+ }
29
+
30
+ if (ruleSet.mode !== 'sentiment') {
31
+ throw new CompilationError(`Expected mode 'sentiment', got '${ruleSet.mode}'`);
32
+ }
33
+
34
+ if (!ruleSet.lexiconConfig || !ruleSet.lexiconConfig.lexicon) {
35
+ throw new CompilationError('Sentiment ruleset requires a lexiconConfig with a lexicon');
36
+ }
37
+
38
+ const lexiconKeys = Object.keys(ruleSet.lexiconConfig.lexicon);
39
+ if (lexiconKeys.length === 0) {
40
+ throw new CompilationError('Lexicon must contain at least one entry');
41
+ }
42
+
43
+ // Compile the lexicon
44
+ const lexicon = compileLexicon(ruleSet.lexiconConfig);
45
+
46
+ // Resolve config defaults
47
+ const config = {
48
+ capsBoost: ruleSet.config?.capsBoost ?? SENTIMENT_DEFAULTS.capsBoost,
49
+ exclamationBoost: ruleSet.config?.exclamationBoost ?? SENTIMENT_DEFAULTS.exclamationBoost,
50
+ negationWindow: ruleSet.config?.negationWindow ?? SENTIMENT_DEFAULTS.negationWindow
51
+ };
52
+
53
+ switch (ruleSet.strategy) {
54
+ case 'token-level':
55
+ return {
56
+ id: ruleSet.id,
57
+ name: ruleSet.name,
58
+ mode: 'sentiment',
59
+ strategy: 'token-level',
60
+ lexicon,
61
+ config
62
+ } satisfies CompiledTokenLevelSentimentRuleSet;
63
+
64
+ case 'document-level': {
65
+ const pattern = ruleSet.sentenceSplitPattern ?? '[.!?]+';
66
+ return {
67
+ id: ruleSet.id,
68
+ name: ruleSet.name,
69
+ mode: 'sentiment',
70
+ strategy: 'document-level',
71
+ lexicon,
72
+ config,
73
+ sentenceSplitPattern: new RegExp(pattern)
74
+ } satisfies CompiledDocumentLevelSentimentRuleSet;
75
+ }
76
+
77
+ case 'aspect-based': {
78
+ if (!ruleSet.aspects || ruleSet.aspects.length === 0) {
79
+ throw new CompilationError('Aspect-based strategy requires at least one aspect');
80
+ }
81
+ const aspects = ruleSet.aspects.map(a => a.toLowerCase());
82
+ return {
83
+ id: ruleSet.id,
84
+ name: ruleSet.name,
85
+ mode: 'sentiment',
86
+ strategy: 'aspect-based',
87
+ lexicon,
88
+ config,
89
+ aspects
90
+ } satisfies CompiledAspectBasedSentimentRuleSet;
91
+ }
92
+
93
+ default:
94
+ throw new CompilationError(`Unknown sentiment strategy: '${(ruleSet as any).strategy}'`);
95
+ }
96
+ }
97
+
98
+ function compileLexicon(
99
+ input: { lexicon: Record<string, number>; boosters?: Record<string, number>; negation?: string[]; idioms?: Record<string, number> }
100
+ ): CompiledSentimentLexicon {
101
+ // Normalize all keys to lowercase
102
+ const lexicon: Record<string, number> = {};
103
+ for (const [key, value] of Object.entries(input.lexicon)) {
104
+ lexicon[key.toLowerCase()] = value;
105
+ }
106
+
107
+ const boosters: Record<string, number> = {};
108
+ if (input.boosters) {
109
+ for (const [key, value] of Object.entries(input.boosters)) {
110
+ boosters[key.toLowerCase()] = value;
111
+ }
112
+ }
113
+
114
+ const negation = new Set<string>(
115
+ (input.negation ?? []).map(w => w.toLowerCase())
116
+ );
117
+
118
+ const idioms: Record<string, number> = {};
119
+ let idiomMaxLength = 0;
120
+ if (input.idioms) {
121
+ for (const [key, value] of Object.entries(input.idioms)) {
122
+ const normalized = key.toLowerCase();
123
+ idioms[normalized] = value;
124
+ const wordCount = normalized.split(/\s+/).length;
125
+ if (wordCount > idiomMaxLength) {
126
+ idiomMaxLength = wordCount;
127
+ }
128
+ }
129
+ }
130
+
131
+ return {
132
+ lexicon,
133
+ boosters,
134
+ negation,
135
+ idioms,
136
+ _idiomMaxLength: idiomMaxLength
137
+ };
138
+ }
@@ -0,0 +1,274 @@
1
+ /**
2
+ * Sentiment Engine
3
+ *
4
+ * Text sentiment analysis engine that scores text using dictionary-lookup
5
+ * and heuristic rules. Supports token-level, document-level, and aspect-based
6
+ * analysis strategies with injectable lexicon configuration.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const engine = new SentimentEngine();
11
+ * engine.add({ type: 'Review', data: { text: 'The product is absolutely fantastic!' } });
12
+ *
13
+ * const result = engine.execute(compiledRuleset);
14
+ * console.log(result.compound); // 0.85 (positive)
15
+ * ```
16
+ */
17
+
18
+ import {
19
+ WorkingMemory,
20
+ Fact,
21
+ FactInput,
22
+ FactChange
23
+ } from '../../core';
24
+
25
+ import type {
26
+ CompiledSentimentRuleSet,
27
+ SentimentOptions,
28
+ SentimentResult,
29
+ SentimentStrategy,
30
+ IngestResult,
31
+ AspectResult
32
+ } from './types';
33
+ import { resolveSentimentLabel } from './types';
34
+
35
+ import { SentimentExecutor } from './strategy';
36
+
37
+ function round(value: number, decimals: number): number {
38
+ const factor = Math.pow(10, decimals);
39
+ return Math.round(value * factor) / factor;
40
+ }
41
+
42
+ /** Internal accumulator for streaming ingest */
43
+ type StreamState = {
44
+ ruleSetId: string;
45
+ strategy: SentimentStrategy;
46
+ compoundSum: number;
47
+ count: number;
48
+ posTokens: number;
49
+ negTokens: number;
50
+ neuTokens: number;
51
+ totalTokens: number;
52
+ /** Per-aspect accumulators (aspect-based only) */
53
+ aspectAccumulators: Map<string, { compoundSum: number; count: number }>;
54
+ /** Last computed aggregate result (without item-specific fields) */
55
+ lastResult: SentimentResult | null;
56
+ };
57
+
58
+ export class SentimentEngine {
59
+ private wm: WorkingMemory;
60
+ private strategy: SentimentExecutor;
61
+ private _stream: StreamState | null = null;
62
+
63
+ constructor(workingMemory?: WorkingMemory) {
64
+ this.wm = workingMemory ?? new WorkingMemory();
65
+ this.strategy = new SentimentExecutor();
66
+ }
67
+
68
+ // ========================================
69
+ // IWorkingMemory Implementation
70
+ // ========================================
71
+
72
+ add<T = Record<string, any>>(input: FactInput<T>): Fact<T> {
73
+ return this.wm.add(input);
74
+ }
75
+
76
+ remove(factId: string): Fact | undefined {
77
+ return this.wm.remove(factId);
78
+ }
79
+
80
+ update<T = Record<string, any>>(input: FactInput<T>): Fact<T> {
81
+ return this.wm.update(input);
82
+ }
83
+
84
+ get(factId: string): Fact | undefined {
85
+ return this.wm.get(factId);
86
+ }
87
+
88
+ getByType(type: string): Fact[] {
89
+ return this.wm.getByType(type);
90
+ }
91
+
92
+ getAll(): Fact[] {
93
+ return this.wm.getAll();
94
+ }
95
+
96
+ has(factId: string): boolean {
97
+ return this.wm.has(factId);
98
+ }
99
+
100
+ size(): number {
101
+ return this.wm.size();
102
+ }
103
+
104
+ clear(): void {
105
+ this.wm.clear();
106
+ }
107
+
108
+ getChanges(): FactChange[] {
109
+ return this.wm.getChanges();
110
+ }
111
+
112
+ clearChanges(): void {
113
+ this.wm.clearChanges();
114
+ }
115
+
116
+ // ========================================
117
+ // Engine Execution
118
+ // ========================================
119
+
120
+ /**
121
+ * Execute a sentiment analysis ruleset.
122
+ *
123
+ * Extracts text from all facts in working memory, applies the configured
124
+ * sentiment strategy, and returns compound scores with token-level detail.
125
+ *
126
+ * @param ruleSet - Compiled sentiment ruleset
127
+ * @param options - Runtime options (onToken callback)
128
+ * @returns Sentiment result with compound score, label, and detail
129
+ */
130
+ execute(
131
+ ruleSet: CompiledSentimentRuleSet,
132
+ options: SentimentOptions = {}
133
+ ): SentimentResult {
134
+ return this.strategy.run(ruleSet, this.wm, options);
135
+ }
136
+
137
+ // ========================================
138
+ // Streaming Ingest
139
+ // ========================================
140
+
141
+ /**
142
+ * Score a single text incrementally without touching working memory.
143
+ *
144
+ * Each call scores the provided text, updates a running accumulator,
145
+ * and returns both the individual score and the current aggregate.
146
+ * The compiled ruleset must stay the same across calls (matched by id).
147
+ * Call `resetStream()` to start a new stream.
148
+ *
149
+ * @param text - Raw text to score
150
+ * @param ruleSet - Compiled sentiment ruleset
151
+ * @param options - Runtime options (onToken callback)
152
+ * @returns IngestResult with item-level and aggregate scores
153
+ */
154
+ ingest(
155
+ text: string,
156
+ ruleSet: CompiledSentimentRuleSet,
157
+ options: SentimentOptions = {}
158
+ ): IngestResult {
159
+ // Initialize or validate stream state
160
+ if (!this._stream || this._stream.ruleSetId !== ruleSet.id) {
161
+ this._stream = {
162
+ ruleSetId: ruleSet.id,
163
+ strategy: ruleSet.strategy,
164
+ compoundSum: 0,
165
+ count: 0,
166
+ posTokens: 0,
167
+ negTokens: 0,
168
+ neuTokens: 0,
169
+ totalTokens: 0,
170
+ aspectAccumulators: new Map(),
171
+ lastResult: null
172
+ };
173
+ }
174
+
175
+ // Score just this text
176
+ const itemResult = this.strategy.scoreText(ruleSet, text, options);
177
+
178
+ // Update running accumulators
179
+ const s = this._stream;
180
+ s.compoundSum += itemResult.compound;
181
+ s.count++;
182
+
183
+ // Update token proportion accumulators
184
+ const itemTokenTotal = itemResult.tokens?.length
185
+ ?? itemResult.sentences?.reduce((n, sent) => n + sent.tokens.length, 0)
186
+ ?? itemResult.aspects?.reduce((n, a) => n + a.sentences.reduce((m, sent) => m + sent.tokens.length, 0), 0)
187
+ ?? 0;
188
+
189
+ if (itemTokenTotal > 0) {
190
+ s.posTokens += Math.round(itemResult.positive * itemTokenTotal);
191
+ s.negTokens += Math.round(itemResult.negative * itemTokenTotal);
192
+ s.neuTokens += Math.round(itemResult.neutral * itemTokenTotal);
193
+ s.totalTokens += itemTokenTotal;
194
+ }
195
+
196
+ // Update aspect accumulators if aspect-based
197
+ if (itemResult.aspects) {
198
+ for (const aspect of itemResult.aspects) {
199
+ if (aspect.sentences.length === 0) continue;
200
+ let acc = s.aspectAccumulators.get(aspect.aspect);
201
+ if (!acc) {
202
+ acc = { compoundSum: 0, count: 0 };
203
+ s.aspectAccumulators.set(aspect.aspect, acc);
204
+ }
205
+ acc.compoundSum += aspect.compound;
206
+ acc.count++;
207
+ }
208
+ }
209
+
210
+ // Compute aggregate
211
+ const aggCompound = round(s.compoundSum / s.count, 4);
212
+ const aggPositive = s.totalTokens > 0 ? round(s.posTokens / s.totalTokens, 4) : 0;
213
+ const aggNegative = s.totalTokens > 0 ? round(s.negTokens / s.totalTokens, 4) : 0;
214
+ const aggNeutral = s.totalTokens > 0 ? round(s.neuTokens / s.totalTokens, 4) : 0;
215
+
216
+ // Build aggregate aspect results if applicable
217
+ let aggAspects: AspectResult[] | undefined;
218
+ if (s.aspectAccumulators.size > 0) {
219
+ aggAspects = [];
220
+ for (const [aspect, acc] of s.aspectAccumulators) {
221
+ const aspectCompound = round(acc.compoundSum / acc.count, 4);
222
+ aggAspects.push({
223
+ aspect,
224
+ compound: aspectCompound,
225
+ label: resolveSentimentLabel(aspectCompound),
226
+ sentences: []
227
+ });
228
+ }
229
+ }
230
+
231
+ const aggregate: SentimentResult = {
232
+ compound: aggCompound,
233
+ label: resolveSentimentLabel(aggCompound),
234
+ positive: aggPositive,
235
+ negative: aggNegative,
236
+ neutral: aggNeutral,
237
+ aspects: aggAspects,
238
+ strategy: ruleSet.strategy,
239
+ executionTimeMs: itemResult.executionTimeMs
240
+ };
241
+
242
+ s.lastResult = aggregate;
243
+
244
+ return {
245
+ ...aggregate,
246
+ itemCompound: itemResult.compound,
247
+ itemLabel: itemResult.label,
248
+ totalIngested: s.count
249
+ };
250
+ }
251
+
252
+ /**
253
+ * Get the current streaming aggregate without ingesting new text.
254
+ * Returns null if no texts have been ingested yet.
255
+ */
256
+ getStreamResult(): SentimentResult | null {
257
+ return this._stream?.lastResult ?? null;
258
+ }
259
+
260
+ /**
261
+ * Reset the streaming accumulator. Does not affect working memory.
262
+ */
263
+ resetStream(): void {
264
+ this._stream = null;
265
+ }
266
+
267
+ // ========================================
268
+ // Utility Methods
269
+ // ========================================
270
+
271
+ getWorkingMemory(): WorkingMemory {
272
+ return this.wm;
273
+ }
274
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Sentiment Engine -- Text Sentiment Analysis
3
+ */
4
+
5
+ // Types
6
+ export type {
7
+ SentimentStrategy,
8
+ SentimentLabel,
9
+ SentimentLexicon,
10
+ CompiledSentimentLexicon,
11
+ SentimentConfig,
12
+ TokenLevelSentimentRuleSet,
13
+ DocumentLevelSentimentRuleSet,
14
+ AspectBasedSentimentRuleSet,
15
+ SentimentRuleSet,
16
+ CompiledTokenLevelSentimentRuleSet,
17
+ CompiledDocumentLevelSentimentRuleSet,
18
+ CompiledAspectBasedSentimentRuleSet,
19
+ CompiledSentimentRuleSet,
20
+ TokenModifier,
21
+ TokenScore,
22
+ SentenceResult,
23
+ AspectResult,
24
+ SentimentResult,
25
+ SentimentOptions,
26
+ IngestResult
27
+ } from './types';
28
+
29
+ // Constants & utilities
30
+ export {
31
+ SENTIMENT_DEFAULTS,
32
+ resolveSentimentLabel
33
+ } from './types';
34
+
35
+ // Compiler
36
+ export { compileSentimentRuleSet } from './compiler';
37
+
38
+ // Strategy
39
+ export { SentimentExecutor, sentimentStrategy } from './strategy';
40
+
41
+ // Engine
42
+ export { SentimentEngine } from './engine';