@txn-signal/lang-en 0.1.0
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/.turbo/turbo-build.log +5 -0
- package/.turbo/turbo-lint.log +6 -0
- package/.turbo/turbo-test.log +14 -0
- package/.turbo/turbo-typecheck.log +5 -0
- package/dist/core/src/analyze.d.ts +9 -0
- package/dist/core/src/analyze.d.ts.map +1 -0
- package/dist/core/src/analyze.js +5 -0
- package/dist/core/src/analyze.js.map +1 -0
- package/dist/core/src/domain/enums.d.ts +41 -0
- package/dist/core/src/domain/enums.d.ts.map +1 -0
- package/dist/core/src/domain/enums.js +46 -0
- package/dist/core/src/domain/enums.js.map +1 -0
- package/dist/core/src/domain/event-type.d.ts +12 -0
- package/dist/core/src/domain/event-type.d.ts.map +1 -0
- package/dist/core/src/domain/event-type.js +13 -0
- package/dist/core/src/domain/event-type.js.map +1 -0
- package/dist/core/src/domain/explain.d.ts +8 -0
- package/dist/core/src/domain/explain.d.ts.map +1 -0
- package/dist/core/src/domain/explain.js +2 -0
- package/dist/core/src/domain/explain.js.map +1 -0
- package/dist/core/src/domain/fingerprint.d.ts +2 -0
- package/dist/core/src/domain/fingerprint.d.ts.map +1 -0
- package/dist/core/src/domain/fingerprint.js +9 -0
- package/dist/core/src/domain/fingerprint.js.map +1 -0
- package/dist/core/src/domain/metadata.d.ts +21 -0
- package/dist/core/src/domain/metadata.d.ts.map +1 -0
- package/dist/core/src/domain/metadata.js +2 -0
- package/dist/core/src/domain/metadata.js.map +1 -0
- package/dist/core/src/domain/signal.d.ts +18 -0
- package/dist/core/src/domain/signal.d.ts.map +1 -0
- package/dist/core/src/domain/signal.js +2 -0
- package/dist/core/src/domain/signal.js.map +1 -0
- package/dist/core/src/grammar/structural-extractor.d.ts +4 -0
- package/dist/core/src/grammar/structural-extractor.d.ts.map +1 -0
- package/dist/core/src/grammar/structural-extractor.js +99 -0
- package/dist/core/src/grammar/structural-extractor.js.map +1 -0
- package/dist/core/src/grammar/types.d.ts +13 -0
- package/dist/core/src/grammar/types.d.ts.map +1 -0
- package/dist/core/src/grammar/types.js +2 -0
- package/dist/core/src/grammar/types.js.map +1 -0
- package/dist/core/src/index.d.ts +12 -0
- package/dist/core/src/index.d.ts.map +1 -0
- package/dist/core/src/index.js +8 -0
- package/dist/core/src/index.js.map +1 -0
- package/dist/core/src/pipeline/gate1-prefilter.d.ts +4 -0
- package/dist/core/src/pipeline/gate1-prefilter.d.ts.map +1 -0
- package/dist/core/src/pipeline/gate1-prefilter.js +35 -0
- package/dist/core/src/pipeline/gate1-prefilter.js.map +1 -0
- package/dist/core/src/pipeline/gate2-structural.d.ts +4 -0
- package/dist/core/src/pipeline/gate2-structural.d.ts.map +1 -0
- package/dist/core/src/pipeline/gate2-structural.js +14 -0
- package/dist/core/src/pipeline/gate2-structural.js.map +1 -0
- package/dist/core/src/pipeline/gate3-semantic.d.ts +4 -0
- package/dist/core/src/pipeline/gate3-semantic.d.ts.map +1 -0
- package/dist/core/src/pipeline/gate3-semantic.js +70 -0
- package/dist/core/src/pipeline/gate3-semantic.js.map +1 -0
- package/dist/core/src/pipeline/grammar-engine.d.ts +9 -0
- package/dist/core/src/pipeline/grammar-engine.d.ts.map +1 -0
- package/dist/core/src/pipeline/grammar-engine.js +19 -0
- package/dist/core/src/pipeline/grammar-engine.js.map +1 -0
- package/dist/core/src/pipeline/interpretation.d.ts +16 -0
- package/dist/core/src/pipeline/interpretation.d.ts.map +1 -0
- package/dist/core/src/pipeline/interpretation.js +89 -0
- package/dist/core/src/pipeline/interpretation.js.map +1 -0
- package/dist/core/src/pipeline/metadata-detector.d.ts +14 -0
- package/dist/core/src/pipeline/metadata-detector.d.ts.map +1 -0
- package/dist/core/src/pipeline/metadata-detector.js +58 -0
- package/dist/core/src/pipeline/metadata-detector.js.map +1 -0
- package/dist/core/src/pipeline/normalization.d.ts +12 -0
- package/dist/core/src/pipeline/normalization.d.ts.map +1 -0
- package/dist/core/src/pipeline/normalization.js +46 -0
- package/dist/core/src/pipeline/normalization.js.map +1 -0
- package/dist/core/src/pipeline/orchestrator.d.ts +4 -0
- package/dist/core/src/pipeline/orchestrator.d.ts.map +1 -0
- package/dist/core/src/pipeline/orchestrator.js +117 -0
- package/dist/core/src/pipeline/orchestrator.js.map +1 -0
- package/dist/core/src/pipeline/plugin-refinement.d.ts +8 -0
- package/dist/core/src/pipeline/plugin-refinement.d.ts.map +1 -0
- package/dist/core/src/pipeline/plugin-refinement.js +34 -0
- package/dist/core/src/pipeline/plugin-refinement.js.map +1 -0
- package/dist/core/src/pipeline/role-tagger.d.ts +9 -0
- package/dist/core/src/pipeline/role-tagger.d.ts.map +1 -0
- package/dist/core/src/pipeline/role-tagger.js +36 -0
- package/dist/core/src/pipeline/role-tagger.js.map +1 -0
- package/dist/core/src/pipeline/scoring.d.ts +11 -0
- package/dist/core/src/pipeline/scoring.d.ts.map +1 -0
- package/dist/core/src/pipeline/scoring.js +19 -0
- package/dist/core/src/pipeline/scoring.js.map +1 -0
- package/dist/core/src/pipeline/soft-event-mapper.d.ts +9 -0
- package/dist/core/src/pipeline/soft-event-mapper.d.ts.map +1 -0
- package/dist/core/src/pipeline/soft-event-mapper.js +59 -0
- package/dist/core/src/pipeline/soft-event-mapper.js.map +1 -0
- package/dist/core/src/pipeline/tokenizer.d.ts +9 -0
- package/dist/core/src/pipeline/tokenizer.d.ts.map +1 -0
- package/dist/core/src/pipeline/tokenizer.js +27 -0
- package/dist/core/src/pipeline/tokenizer.js.map +1 -0
- package/dist/core/src/pipeline/trait-extractor.d.ts +31 -0
- package/dist/core/src/pipeline/trait-extractor.d.ts.map +1 -0
- package/dist/core/src/pipeline/trait-extractor.js +36 -0
- package/dist/core/src/pipeline/trait-extractor.js.map +1 -0
- package/dist/core/src/plugins/plugin-runner.d.ts +3 -0
- package/dist/core/src/plugins/plugin-runner.d.ts.map +1 -0
- package/dist/core/src/plugins/plugin-runner.js +13 -0
- package/dist/core/src/plugins/plugin-runner.js.map +1 -0
- package/dist/core/src/registry/language-registry.d.ts +5 -0
- package/dist/core/src/registry/language-registry.d.ts.map +1 -0
- package/dist/core/src/registry/language-registry.js +17 -0
- package/dist/core/src/registry/language-registry.js.map +1 -0
- package/dist/core/src/registry/plugin-registry.d.ts +4 -0
- package/dist/core/src/registry/plugin-registry.d.ts.map +1 -0
- package/dist/core/src/registry/plugin-registry.js +13 -0
- package/dist/core/src/registry/plugin-registry.js.map +1 -0
- package/dist/core/src/registry/rail-registry.d.ts +4 -0
- package/dist/core/src/registry/rail-registry.d.ts.map +1 -0
- package/dist/core/src/registry/rail-registry.js +13 -0
- package/dist/core/src/registry/rail-registry.js.map +1 -0
- package/dist/core/src/registry/types.d.ts +32 -0
- package/dist/core/src/registry/types.d.ts.map +1 -0
- package/dist/core/src/registry/types.js +2 -0
- package/dist/core/src/registry/types.js.map +1 -0
- package/dist/core/src/roles/role-tagger.d.ts +5 -0
- package/dist/core/src/roles/role-tagger.d.ts.map +1 -0
- package/dist/core/src/roles/role-tagger.js +209 -0
- package/dist/core/src/roles/role-tagger.js.map +1 -0
- package/dist/core/src/roles/role-types.d.ts +36 -0
- package/dist/core/src/roles/role-types.d.ts.map +1 -0
- package/dist/core/src/roles/role-types.js +28 -0
- package/dist/core/src/roles/role-types.js.map +1 -0
- package/dist/core/src/scoring/scoring-engine.d.ts +7 -0
- package/dist/core/src/scoring/scoring-engine.d.ts.map +1 -0
- package/dist/core/src/scoring/scoring-engine.js +32 -0
- package/dist/core/src/scoring/scoring-engine.js.map +1 -0
- package/dist/core/src/scoring/weights.d.ts +13 -0
- package/dist/core/src/scoring/weights.d.ts.map +1 -0
- package/dist/core/src/scoring/weights.js +13 -0
- package/dist/core/src/scoring/weights.js.map +1 -0
- package/dist/core/src/tokenization/semantic-tokenizer.d.ts +3 -0
- package/dist/core/src/tokenization/semantic-tokenizer.d.ts.map +1 -0
- package/dist/core/src/tokenization/semantic-tokenizer.js +207 -0
- package/dist/core/src/tokenization/semantic-tokenizer.js.map +1 -0
- package/dist/core/src/tokenization/token-types.d.ts +25 -0
- package/dist/core/src/tokenization/token-types.d.ts.map +1 -0
- package/dist/core/src/tokenization/token-types.js +13 -0
- package/dist/core/src/tokenization/token-types.js.map +1 -0
- package/dist/core/src/tokenization/tokenizer-registry.d.ts +9 -0
- package/dist/core/src/tokenization/tokenizer-registry.d.ts.map +1 -0
- package/dist/core/src/tokenization/tokenizer-registry.js +9 -0
- package/dist/core/src/tokenization/tokenizer-registry.js.map +1 -0
- package/dist/core/src/types.d.ts +11 -0
- package/dist/core/src/types.d.ts.map +1 -0
- package/dist/core/src/types.js +2 -0
- package/dist/core/src/types.js.map +1 -0
- package/dist/core/src/utils/string.d.ts +3 -0
- package/dist/core/src/utils/string.d.ts.map +1 -0
- package/dist/core/src/utils/string.js +7 -0
- package/dist/core/src/utils/string.js.map +1 -0
- package/dist/core/src/version.d.ts +2 -0
- package/dist/core/src/version.d.ts.map +1 -0
- package/dist/core/src/version.js +2 -0
- package/dist/core/src/version.js.map +1 -0
- package/dist/lang-en/src/index.d.ts +2 -0
- package/dist/lang-en/src/index.d.ts.map +1 -0
- package/dist/lang-en/src/index.js +12 -0
- package/dist/lang-en/src/index.js.map +1 -0
- package/dist/lang-en/src/lexicon.d.ts +12 -0
- package/dist/lang-en/src/lexicon.d.ts.map +1 -0
- package/dist/lang-en/src/lexicon.js +29 -0
- package/dist/lang-en/src/lexicon.js.map +1 -0
- package/package.json +22 -0
- package/src/index.ts +12 -0
- package/src/lexicon.ts +31 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StageResult } from '../types.js';
|
|
2
|
+
import type { Interpreted, InterpretedItem } from './interpretation.js';
|
|
3
|
+
export interface ScoredItem extends InterpretedItem {
|
|
4
|
+
confidence: number;
|
|
5
|
+
scoringBreakdown: Record<string, number>;
|
|
6
|
+
}
|
|
7
|
+
export interface Scored {
|
|
8
|
+
items: ScoredItem[];
|
|
9
|
+
}
|
|
10
|
+
export declare function scoring(interpreted: Interpreted): StageResult<Scored>;
|
|
11
|
+
//# sourceMappingURL=scoring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoring.d.ts","sourceRoot":"","sources":["../../../../../core/src/pipeline/scoring.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,WAAW,UAAW,SAAQ,eAAe;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED,wBAAgB,OAAO,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAmBrE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FundingSourceType, PaymentRail } from '../domain/enums.js';
|
|
2
|
+
import { scoreCandidate } from '../scoring/scoring-engine.js';
|
|
3
|
+
export function scoring(interpreted) {
|
|
4
|
+
const items = interpreted.interpreted.map(item => {
|
|
5
|
+
const hasRail = item.metadata.paymentRail !== PaymentRail.Unknown;
|
|
6
|
+
const hasSource = item.metadata.fundingSourceType !== FundingSourceType.Unknown;
|
|
7
|
+
const result = scoreCandidate(item.candidate.eventType, hasRail, hasSource);
|
|
8
|
+
return {
|
|
9
|
+
...item,
|
|
10
|
+
confidence: result.score,
|
|
11
|
+
scoringBreakdown: result.breakdown,
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
type: 'Continue',
|
|
16
|
+
data: { items },
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=scoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoring.js","sourceRoot":"","sources":["../../../../../core/src/pipeline/scoring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAa9D,MAAM,UAAU,OAAO,CAAC,WAAwB;IAE9C,MAAM,KAAK,GAAiB,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,KAAK,WAAW,CAAC,OAAO,CAAC;QAClE,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,KAAK,iBAAiB,CAAC,OAAO,CAAC;QAEhF,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAE5E,OAAO;YACL,GAAG,IAAI;YACP,UAAU,EAAE,MAAM,CAAC,KAAK;YACxB,gBAAgB,EAAE,MAAM,CAAC,SAAS;SACnC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,EAAE,KAAK,EAAE;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TransactionCandidate } from '../grammar/types.js';
|
|
2
|
+
import type { StageResult } from '../types.js';
|
|
3
|
+
import type { TraitEnriched } from './trait-extractor.js';
|
|
4
|
+
export interface EventClassified {
|
|
5
|
+
tagged: TraitEnriched['tagged'];
|
|
6
|
+
candidates: TransactionCandidate[];
|
|
7
|
+
}
|
|
8
|
+
export declare function softEventMapper(enriched: TraitEnriched): StageResult<EventClassified>;
|
|
9
|
+
//# sourceMappingURL=soft-event-mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"soft-event-mapper.d.ts","sourceRoot":"","sources":["../../../../../core/src/pipeline/soft-event-mapper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC5B,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,UAAU,EAAE,oBAAoB,EAAE,CAAC;CACtC;AA2DD,wBAAgB,eAAe,CAC3B,QAAQ,EAAE,aAAa,GACxB,WAAW,CAAC,eAAe,CAAC,CAa9B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { EventType } from '../domain/event-type.js';
|
|
2
|
+
function mapEventType(item) {
|
|
3
|
+
const { candidate, traits } = item;
|
|
4
|
+
const direction = traits.direction;
|
|
5
|
+
const sourceType = candidate.sourceType;
|
|
6
|
+
const isCardContext = traits.isCardContext || sourceType === 'card';
|
|
7
|
+
const isBankContext = traits.isBankContext ||
|
|
8
|
+
sourceType === 'bank' ||
|
|
9
|
+
traits.hasSourceAccount ||
|
|
10
|
+
traits.hasRail;
|
|
11
|
+
if (traits.isRefund)
|
|
12
|
+
return EventType.Refund;
|
|
13
|
+
if (traits.isReversal)
|
|
14
|
+
return EventType.Reversal;
|
|
15
|
+
if (traits.isCashback)
|
|
16
|
+
return EventType.Cashback;
|
|
17
|
+
if (traits.hasPaymentTowardCardCue &&
|
|
18
|
+
isCardContext) {
|
|
19
|
+
return EventType.LiabilityPayment;
|
|
20
|
+
}
|
|
21
|
+
if (traits.isPaymentKeyword &&
|
|
22
|
+
isCardContext &&
|
|
23
|
+
direction === 'credit') {
|
|
24
|
+
return EventType.LiabilityPayment;
|
|
25
|
+
}
|
|
26
|
+
if (traits.isAuthorization)
|
|
27
|
+
return EventType.Authorization;
|
|
28
|
+
if (traits.hasSourceAccount && traits.hasDestinationAccount) {
|
|
29
|
+
return EventType.InternalTransfer;
|
|
30
|
+
}
|
|
31
|
+
if (direction === 'debit' && isCardContext) {
|
|
32
|
+
return EventType.CardPurchase;
|
|
33
|
+
}
|
|
34
|
+
if (direction === 'debit')
|
|
35
|
+
return EventType.BankDebit;
|
|
36
|
+
if (direction === 'credit')
|
|
37
|
+
return EventType.BankCredit;
|
|
38
|
+
if (isCardContext && (traits.isTransactionKeyword || traits.isPaymentKeyword)) {
|
|
39
|
+
return EventType.CardPurchase;
|
|
40
|
+
}
|
|
41
|
+
if (isBankContext) {
|
|
42
|
+
return EventType.BankDebit;
|
|
43
|
+
}
|
|
44
|
+
return EventType.BankDebit;
|
|
45
|
+
}
|
|
46
|
+
export function softEventMapper(enriched) {
|
|
47
|
+
const candidates = enriched.items.map(item => ({
|
|
48
|
+
...item.candidate,
|
|
49
|
+
eventType: mapEventType(item),
|
|
50
|
+
}));
|
|
51
|
+
return {
|
|
52
|
+
type: 'Continue',
|
|
53
|
+
data: {
|
|
54
|
+
tagged: enriched.tagged,
|
|
55
|
+
candidates,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=soft-event-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"soft-event-mapper.js","sourceRoot":"","sources":["../../../../../core/src/pipeline/soft-event-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAUpD,SAAS,YAAY,CACjB,IAAoC;IAEpC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAEnC,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACnC,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;IACxC,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,UAAU,KAAK,MAAM,CAAC;IACpE,MAAM,aAAa,GACf,MAAM,CAAC,aAAa;QACpB,UAAU,KAAK,MAA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B,MAAM,UAAU,GAA2B,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnE,GAAG,IAAI,CAAC,SAAS;QACjB,SAAS,EAAE,YAAY,CAAC,IAAI,CAAC;KAChC,CAAC,CAAC,CAAC;IAEJ,OAAO;QACH,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE;YACF,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,UAAU;SACb;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StageResult } from '../types.js';
|
|
2
|
+
import type { Token } from '../tokenization/token-types.js';
|
|
3
|
+
import type { Normalized } from './normalization.js';
|
|
4
|
+
export interface Tokenized {
|
|
5
|
+
normalized: Normalized;
|
|
6
|
+
tokens: Token[];
|
|
7
|
+
}
|
|
8
|
+
export declare function tokenizeStage(normalized: Normalized): StageResult<Tokenized>;
|
|
9
|
+
//# sourceMappingURL=tokenizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../../../../../core/src/pipeline/tokenizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAID,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,CA0B5E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { semanticTokenize } from '../tokenization/semantic-tokenizer.js';
|
|
2
|
+
const MAX_TOKEN_LIMIT = 1000;
|
|
3
|
+
export function tokenizeStage(normalized) {
|
|
4
|
+
const tokens = semanticTokenize(normalized.cleaned);
|
|
5
|
+
if (!Array.isArray(tokens) || tokens.length === 0) {
|
|
6
|
+
return {
|
|
7
|
+
type: 'Rejected',
|
|
8
|
+
stage: 'Tokenizer',
|
|
9
|
+
reason: 'No tokens produced',
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (tokens.length > MAX_TOKEN_LIMIT) {
|
|
13
|
+
return {
|
|
14
|
+
type: 'Rejected',
|
|
15
|
+
stage: 'Tokenizer',
|
|
16
|
+
reason: 'Token limit exceeded',
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
type: 'Continue',
|
|
21
|
+
data: {
|
|
22
|
+
normalized,
|
|
23
|
+
tokens,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=tokenizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenizer.js","sourceRoot":"","sources":["../../../../../core/src/pipeline/tokenizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AASzE,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,MAAM,UAAU,aAAa,CAAC,UAAsB;IAClD,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAEpD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,WAAW;YAClB,MAAM,EAAE,oBAAoB;SAC7B,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,eAAe,EAAE,CAAC;QACpC,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,WAAW;YAClB,MAAM,EAAE,sBAAsB;SAC/B,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE;YACJ,UAAU;YACV,MAAM;SACP;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { StageResult } from '../types.js';
|
|
2
|
+
import type { StructuralCandidate } from '../grammar/types.js';
|
|
3
|
+
import type { GrammarMatched } from './grammar-engine.js';
|
|
4
|
+
export interface TransactionTraits {
|
|
5
|
+
direction?: 'debit' | 'credit';
|
|
6
|
+
isCardContext: boolean;
|
|
7
|
+
isBankContext: boolean;
|
|
8
|
+
isPaymentKeyword: boolean;
|
|
9
|
+
isTransactionKeyword: boolean;
|
|
10
|
+
isRefund: boolean;
|
|
11
|
+
isReversal: boolean;
|
|
12
|
+
isCashback: boolean;
|
|
13
|
+
isAuthorization: boolean;
|
|
14
|
+
hasRail: boolean;
|
|
15
|
+
hasSourceAccount: boolean;
|
|
16
|
+
hasDestinationAccount: boolean;
|
|
17
|
+
hasReference: boolean;
|
|
18
|
+
hasPaymentTowardCardCue: boolean;
|
|
19
|
+
hasMarketingCue: boolean;
|
|
20
|
+
hasBillingCue: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface TraitEnrichedItem {
|
|
23
|
+
candidate: StructuralCandidate;
|
|
24
|
+
traits: TransactionTraits;
|
|
25
|
+
}
|
|
26
|
+
export interface TraitEnriched {
|
|
27
|
+
tagged: GrammarMatched['tagged'];
|
|
28
|
+
items: TraitEnrichedItem[];
|
|
29
|
+
}
|
|
30
|
+
export declare function traitExtractor(matched: GrammarMatched): StageResult<TraitEnriched>;
|
|
31
|
+
//# sourceMappingURL=trait-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trait-extractor.d.ts","sourceRoot":"","sources":["../../../../../core/src/pipeline/trait-extractor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,WAAW,iBAAiB;IAC9B,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,YAAY,EAAE,OAAO,CAAC;IACtB,uBAAuB,EAAE,OAAO,CAAC;IACjC,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAC9B,SAAS,EAAE,mBAAmB,CAAC;IAC/B,MAAM,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IACjC,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED,wBAAgB,cAAc,CAC1B,OAAO,EAAE,cAAc,GACxB,WAAW,CAAC,aAAa,CAAC,CAuC5B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Role } from '../roles/role-types.js';
|
|
2
|
+
export function traitExtractor(matched) {
|
|
3
|
+
const tags = matched.tagged.tags;
|
|
4
|
+
const items = matched.candidates.map(candidate => {
|
|
5
|
+
const direction = candidate.directionHint;
|
|
6
|
+
const traits = {
|
|
7
|
+
...(direction ? { direction } : {}),
|
|
8
|
+
isCardContext: tags.some(t => t.role === Role.CardContext),
|
|
9
|
+
isBankContext: tags.some(t => t.role === Role.BankContext),
|
|
10
|
+
isPaymentKeyword: tags.some(t => t.role === Role.PaymentKeyword),
|
|
11
|
+
isTransactionKeyword: tags.some(t => t.role === Role.TransactionKeyword),
|
|
12
|
+
isRefund: tags.some(t => t.role === Role.RefundCue) ||
|
|
13
|
+
tags.some(t => t.role === Role.DirectionVerb && /^refund(?:ed)?$/i.test(t.value)),
|
|
14
|
+
isReversal: tags.some(t => t.role === Role.ReversalCue) ||
|
|
15
|
+
tags.some(t => t.role === Role.DirectionVerb && /^reversed?$/i.test(t.value)),
|
|
16
|
+
isCashback: tags.some(t => t.role === Role.CashbackCue),
|
|
17
|
+
isAuthorization: tags.some(t => t.role === Role.AuthorizationCue),
|
|
18
|
+
hasRail: tags.some(t => t.role === Role.RailKeyword),
|
|
19
|
+
hasSourceAccount: tags.some(t => t.role === Role.SourceAccount),
|
|
20
|
+
hasDestinationAccount: tags.some(t => t.role === Role.DestinationAccount),
|
|
21
|
+
hasReference: tags.some(t => t.role === Role.ReferenceNumber),
|
|
22
|
+
hasPaymentTowardCardCue: tags.some(t => t.role === Role.PaymentTowardCardCue),
|
|
23
|
+
hasMarketingCue: tags.some(t => t.role === Role.MarketingCue),
|
|
24
|
+
hasBillingCue: tags.some(t => t.role === Role.BillingCue),
|
|
25
|
+
};
|
|
26
|
+
return { candidate, traits };
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
type: 'Continue',
|
|
30
|
+
data: {
|
|
31
|
+
tagged: matched.tagged,
|
|
32
|
+
items,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=trait-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trait-extractor.js","sourceRoot":"","sources":["../../../../../core/src/pipeline/trait-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAkC9C,MAAM,UAA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C,CAAC,CAAC;IAEH,OAAO;QACH,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,KAAK;SACR;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-runner.d.ts","sourceRoot":"","sources":["../../../../../core/src/plugins/plugin-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEpF,wBAAgB,UAAU,CAAC,IAAI,EAAE,oBAAoB,EAAE,GAAG,EAAE,iBAAiB,GAAG,oBAAoB,CAanG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { listPlugins } from '../registry/plugin-registry.js';
|
|
2
|
+
export function runPlugins(base, ctx) {
|
|
3
|
+
const updated = { ...base };
|
|
4
|
+
for (const plugin of listPlugins()) {
|
|
5
|
+
if (!plugin.canHandle(ctx)) {
|
|
6
|
+
continue;
|
|
7
|
+
}
|
|
8
|
+
const patch = plugin.refine(updated, ctx);
|
|
9
|
+
Object.assign(updated, patch);
|
|
10
|
+
}
|
|
11
|
+
return updated;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=plugin-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-runner.js","sourceRoot":"","sources":["../../../../../core/src/plugins/plugin-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG7D,MAAM,UAAU,UAAU,CAAC,IAA0B,EAAE,GAAsB;IAC3E,MAAM,OAAO,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAE5B,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,SAAS;QACX,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LanguagePack } from './types.js';
|
|
2
|
+
export declare function registerLanguagePack(pack: LanguagePack): void;
|
|
3
|
+
export declare function getLanguagePack(code: string): LanguagePack | undefined;
|
|
4
|
+
export declare function listLanguagePacks(): readonly LanguagePack[];
|
|
5
|
+
//# sourceMappingURL=language-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-registry.d.ts","sourceRoot":"","sources":["../../../../../core/src/registry/language-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK/C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAK7D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAGtE;AAED,wBAAgB,iBAAiB,IAAI,SAAS,YAAY,EAAE,CAG3D"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const languagePacks = new Map();
|
|
2
|
+
let frozen = false;
|
|
3
|
+
export function registerLanguagePack(pack) {
|
|
4
|
+
if (frozen) {
|
|
5
|
+
throw new Error('Language registry is readonly after boot.');
|
|
6
|
+
}
|
|
7
|
+
languagePacks.set(pack.code, pack);
|
|
8
|
+
}
|
|
9
|
+
export function getLanguagePack(code) {
|
|
10
|
+
frozen = true;
|
|
11
|
+
return languagePacks.get(code);
|
|
12
|
+
}
|
|
13
|
+
export function listLanguagePacks() {
|
|
14
|
+
frozen = true;
|
|
15
|
+
return [...languagePacks.values()];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=language-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-registry.js","sourceRoot":"","sources":["../../../../../core/src/registry/language-registry.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;AACtD,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,MAAM,UAAU,oBAAoB,CAAC,IAAkB;IACrD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IACD,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,GAAG,IAAI,CAAC;IACd,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,MAAM,GAAG,IAAI,CAAC;IACd,OAAO,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../../../../../core/src/registry/plugin-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAKnD,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAK7D;AAED,wBAAgB,WAAW,IAAI,SAAS,gBAAgB,EAAE,CAGzD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const plugins = [];
|
|
2
|
+
let frozen = false;
|
|
3
|
+
export function registerPlugin(plugin) {
|
|
4
|
+
if (frozen) {
|
|
5
|
+
throw new Error('Plugin registry is readonly after boot.');
|
|
6
|
+
}
|
|
7
|
+
plugins.push(plugin);
|
|
8
|
+
}
|
|
9
|
+
export function listPlugins() {
|
|
10
|
+
frozen = true;
|
|
11
|
+
return [...plugins].sort((left, right) => right.priority - left.priority);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=plugin-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-registry.js","sourceRoot":"","sources":["../../../../../core/src/registry/plugin-registry.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAuB,EAAE,CAAC;AACvC,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,MAAM,UAAU,cAAc,CAAC,MAAwB;IACrD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,MAAM,GAAG,IAAI,CAAC;IACd,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rail-registry.d.ts","sourceRoot":"","sources":["../../../../../core/src/registry/rail-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAKrD;AAED,wBAAgB,aAAa,IAAI,SAAS,QAAQ,EAAE,CAGnD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const railPacks = new Map();
|
|
2
|
+
let frozen = false;
|
|
3
|
+
export function registerRailPack(pack) {
|
|
4
|
+
if (frozen) {
|
|
5
|
+
throw new Error('Rail registry is readonly after boot.');
|
|
6
|
+
}
|
|
7
|
+
railPacks.set(pack.region, pack);
|
|
8
|
+
}
|
|
9
|
+
export function listRailPacks() {
|
|
10
|
+
frozen = true;
|
|
11
|
+
return [...railPacks.values()];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=rail-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rail-registry.js","sourceRoot":"","sources":["../../../../../core/src/registry/rail-registry.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;AAC9C,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,MAAM,UAAU,gBAAgB,CAAC,IAAc;IAC7C,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IACD,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,IAAI,CAAC;IACd,OAAO,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PaymentRail } from '../domain/enums.js';
|
|
2
|
+
import type { TransactionCandidate } from '../grammar/types.js';
|
|
3
|
+
export type { TransactionCandidate } from '../grammar/types.js';
|
|
4
|
+
export interface LanguagePack {
|
|
5
|
+
code: string;
|
|
6
|
+
directionLexicon: {
|
|
7
|
+
debit: readonly string[];
|
|
8
|
+
credit: readonly string[];
|
|
9
|
+
};
|
|
10
|
+
stateLexicon: Record<string, readonly string[]>;
|
|
11
|
+
marketingCues: readonly string[];
|
|
12
|
+
strongAnchors: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
export interface RailKeyword {
|
|
15
|
+
id: PaymentRail;
|
|
16
|
+
keywords: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
export interface RailPack {
|
|
19
|
+
region: string;
|
|
20
|
+
rails: readonly RailKeyword[];
|
|
21
|
+
}
|
|
22
|
+
export interface ExtractionContext {
|
|
23
|
+
cleanedText: string;
|
|
24
|
+
sender?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ExtractionPlugin {
|
|
27
|
+
id: string;
|
|
28
|
+
priority: number;
|
|
29
|
+
canHandle(ctx: ExtractionContext): boolean;
|
|
30
|
+
refine(base: TransactionCandidate, ctx: ExtractionContext): Omit<Partial<TransactionCandidate>, 'eventType'>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../core/src/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE;QAChB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;QACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;KAC3B,CAAC;IACF,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAChD,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,WAAW,CAAC;IAChB,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC3C,MAAM,CACJ,IAAI,EAAE,oBAAoB,EAC1B,GAAG,EAAE,iBAAiB,GACrB,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,WAAW,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../core/src/registry/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type RoleTag } from './role-types.js';
|
|
2
|
+
import type { Token } from '../tokenization/token-types.js';
|
|
3
|
+
import type { LanguagePack } from '../registry/types.js';
|
|
4
|
+
export declare function roleTag(tokens: Token[], languagePack?: LanguagePack): RoleTag[];
|
|
5
|
+
//# sourceMappingURL=role-tagger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role-tagger.d.ts","sourceRoot":"","sources":["../../../../../core/src/roles/role-tagger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAyEzD,wBAAgB,OAAO,CACrB,MAAM,EAAE,KAAK,EAAE,EACf,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,EAAE,CA6KX"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// roles/role-tagger.ts
|
|
2
|
+
import { Role } from './role-types.js';
|
|
3
|
+
import { TokenType } from '../tokenization/token-types.js';
|
|
4
|
+
const CARD_WORDS = new Set(['card', 'cc', 'cardmember', 'creditcard']);
|
|
5
|
+
const BANK_WORDS = new Set(['bank', 'a/c', 'account', 'acct']);
|
|
6
|
+
const TRANSACTION_WORDS = new Set(['txn', 'transaction', 'purchase', 'spent']);
|
|
7
|
+
const PAYMENT_WORDS = new Set(['payment', 'paid']);
|
|
8
|
+
const REFUND_WORDS = new Set(['refund', 'refunded']);
|
|
9
|
+
const REVERSAL_WORDS = new Set(['reversal', 'reversed']);
|
|
10
|
+
const CASHBACK_WORDS = new Set(['cashback']);
|
|
11
|
+
const AUTH_WORDS = new Set(['authorized', 'blocked', 'hold']);
|
|
12
|
+
const RAIL_WORDS = new Set(['upi', 'imps', 'neft', 'ach', 'sepa', 'pix']);
|
|
13
|
+
const TOWARD_WORDS = new Set(['towards', 'toward']);
|
|
14
|
+
const BILLING_WORDS = new Set(['statement', 'due', 'payable']);
|
|
15
|
+
const DEFAULT_MARKETING_WORDS = new Set([
|
|
16
|
+
'offer',
|
|
17
|
+
'win',
|
|
18
|
+
'bonus',
|
|
19
|
+
'exclusive',
|
|
20
|
+
'congratulations',
|
|
21
|
+
'congrats',
|
|
22
|
+
'earned',
|
|
23
|
+
'earn',
|
|
24
|
+
'rewards',
|
|
25
|
+
]);
|
|
26
|
+
const BALANCE_WORDS = new Set(['bal', 'balance']);
|
|
27
|
+
function normalizeWord(value) {
|
|
28
|
+
return (value ?? '').toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
29
|
+
}
|
|
30
|
+
function hasNearbyCardWord(tokens, index) {
|
|
31
|
+
const maxOffset = 4;
|
|
32
|
+
for (let offset = 1; offset <= maxOffset; offset++) {
|
|
33
|
+
const token = tokens[index + offset];
|
|
34
|
+
if (!token)
|
|
35
|
+
break;
|
|
36
|
+
const normalized = normalizeWord(token.raw);
|
|
37
|
+
if (!normalized)
|
|
38
|
+
continue;
|
|
39
|
+
if (normalized === 'card' ||
|
|
40
|
+
normalized === 'cc' ||
|
|
41
|
+
normalized === 'creditcard' ||
|
|
42
|
+
normalized === 'credit') {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
function markBalanceAmounts(tags, tokens) {
|
|
49
|
+
for (const tag of tags) {
|
|
50
|
+
if (tag.role !== Role.Amount)
|
|
51
|
+
continue;
|
|
52
|
+
const prev1 = normalizeWord(tokens[tag.index - 1]?.raw);
|
|
53
|
+
const prev2 = normalizeWord(tokens[tag.index - 2]?.raw);
|
|
54
|
+
const prev3 = normalizeWord(tokens[tag.index - 3]?.raw);
|
|
55
|
+
const hasBalanceContext = BALANCE_WORDS.has(prev1) ||
|
|
56
|
+
(prev2 === 'avl' && prev1 === 'bal') ||
|
|
57
|
+
(prev2 === 'available' && prev1 === 'balance') ||
|
|
58
|
+
(prev3 === 'avl' && prev2 === 'bal' && (prev1 === 'inr' || prev1 === 'rs' || prev1 === 'rs.'));
|
|
59
|
+
if (hasBalanceContext) {
|
|
60
|
+
tag.role = Role.BalanceAmount;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function roleTag(tokens, languagePack) {
|
|
65
|
+
const debitWords = new Set(languagePack?.directionLexicon.debit ?? [
|
|
66
|
+
'debited', 'deducted', 'withdrawn', 'sent'
|
|
67
|
+
]);
|
|
68
|
+
const creditWords = new Set(languagePack?.directionLexicon.credit ?? [
|
|
69
|
+
'credited', 'received', 'deposited'
|
|
70
|
+
]);
|
|
71
|
+
const marketingWords = new Set([
|
|
72
|
+
...DEFAULT_MARKETING_WORDS,
|
|
73
|
+
...(languagePack?.marketingCues ?? []).map(word => word.toLowerCase()),
|
|
74
|
+
]);
|
|
75
|
+
const tags = [];
|
|
76
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
77
|
+
const token = tokens[i];
|
|
78
|
+
if (!token)
|
|
79
|
+
continue;
|
|
80
|
+
const value = token.raw;
|
|
81
|
+
const normalized = value.toLowerCase();
|
|
82
|
+
// ---- Amount
|
|
83
|
+
if (token.type === TokenType.Amount) {
|
|
84
|
+
tags.push({
|
|
85
|
+
value,
|
|
86
|
+
role: Role.Amount,
|
|
87
|
+
index: i,
|
|
88
|
+
meta: {
|
|
89
|
+
currency: token.meta?.currency,
|
|
90
|
+
amountMinor: token.meta?.amountMinor,
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
// ---- Masked Account
|
|
96
|
+
if (token.type === TokenType.MaskedAccount) {
|
|
97
|
+
const prev = normalizeWord(tokens[i - 1]?.raw);
|
|
98
|
+
tags.push({
|
|
99
|
+
value,
|
|
100
|
+
role: prev === 'to' ? Role.DestinationAccount : Role.SourceAccount,
|
|
101
|
+
index: i,
|
|
102
|
+
});
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
// ---- Reference
|
|
106
|
+
if (token.type === TokenType.Reference) {
|
|
107
|
+
tags.push({
|
|
108
|
+
value: token.meta?.referenceValue ?? value,
|
|
109
|
+
role: Role.ReferenceNumber,
|
|
110
|
+
index: i,
|
|
111
|
+
});
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
// ---- Direction
|
|
115
|
+
if (token.type === TokenType.DirectionWord) {
|
|
116
|
+
const verbType = creditWords.has(normalized) ? 'credit' :
|
|
117
|
+
debitWords.has(normalized) ? 'debit' :
|
|
118
|
+
undefined;
|
|
119
|
+
if (verbType) {
|
|
120
|
+
tags.push({
|
|
121
|
+
value,
|
|
122
|
+
role: Role.DirectionVerb,
|
|
123
|
+
index: i,
|
|
124
|
+
meta: { verbType }
|
|
125
|
+
});
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// ---- Card Context
|
|
130
|
+
const next = normalizeWord(tokens[i + 1]?.raw);
|
|
131
|
+
if (CARD_WORDS.has(normalized) || (normalized === 'credit' && next === 'card')) {
|
|
132
|
+
tags.push({ value, role: Role.CardContext, index: i });
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
// ---- Bank Context
|
|
136
|
+
if (BANK_WORDS.has(normalized)) {
|
|
137
|
+
tags.push({ value, role: Role.BankContext, index: i });
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
// ---- Transaction Keyword
|
|
141
|
+
if (TRANSACTION_WORDS.has(normalized)) {
|
|
142
|
+
tags.push({ value, role: Role.TransactionKeyword, index: i });
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
// ---- Payment Keyword
|
|
146
|
+
if (PAYMENT_WORDS.has(normalized)) {
|
|
147
|
+
tags.push({ value, role: Role.PaymentKeyword, index: i });
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
// ---- Payment Toward Credit Card Cue
|
|
151
|
+
if (TOWARD_WORDS.has(normalized) && hasNearbyCardWord(tokens, i)) {
|
|
152
|
+
tags.push({ value, role: Role.PaymentTowardCardCue, index: i });
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
// ---- Refund
|
|
156
|
+
if (REFUND_WORDS.has(normalized)) {
|
|
157
|
+
tags.push({ value, role: Role.RefundCue, index: i });
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
// ---- Reversal
|
|
161
|
+
if (REVERSAL_WORDS.has(normalized)) {
|
|
162
|
+
tags.push({ value, role: Role.ReversalCue, index: i });
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
// ---- Cashback
|
|
166
|
+
if (CASHBACK_WORDS.has(normalized)) {
|
|
167
|
+
tags.push({ value, role: Role.CashbackCue, index: i });
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
// ---- Authorization
|
|
171
|
+
if (AUTH_WORDS.has(normalized)) {
|
|
172
|
+
tags.push({ value, role: Role.AuthorizationCue, index: i });
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
// ---- Billing Cue
|
|
176
|
+
if (BILLING_WORDS.has(normalized)) {
|
|
177
|
+
tags.push({ value, role: Role.BillingCue, index: i });
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
// ---- Rail
|
|
181
|
+
if (RAIL_WORDS.has(normalized)) {
|
|
182
|
+
tags.push({ value, role: Role.RailKeyword, index: i });
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
// ---- Marketing Cue
|
|
186
|
+
if (marketingWords.has(normalized)) {
|
|
187
|
+
tags.push({ value, role: Role.MarketingCue, index: i });
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
// ---- Merchant Detection
|
|
191
|
+
const prev = tokens[i - 1]?.raw.toLowerCase();
|
|
192
|
+
if (prev === 'at' || prev === 'to' || prev === 'for') {
|
|
193
|
+
tags.push({
|
|
194
|
+
value,
|
|
195
|
+
role: Role.MerchantCandidate,
|
|
196
|
+
index: i,
|
|
197
|
+
});
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
tags.push({
|
|
201
|
+
value,
|
|
202
|
+
role: Role.Noise,
|
|
203
|
+
index: i,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
markBalanceAmounts(tags, tokens);
|
|
207
|
+
return tags;
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=role-tagger.js.map
|