@willwade/aac-processors 0.1.21 → 0.2.1
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 +3 -2
- package/dist/browser/processors/applePanelsProcessor.js +24 -24
- package/dist/browser/processors/astericsGridProcessor.js +22 -24
- package/dist/browser/processors/dotProcessor.js +6 -10
- package/dist/browser/processors/gridset/helpers.js +33 -30
- package/dist/browser/processors/gridset/symbolExtractor.js +2 -2
- package/dist/browser/processors/gridset/symbolSearch.js +22 -22
- package/dist/browser/processors/gridset/symbols.js +14 -14
- package/dist/browser/processors/gridsetProcessor.js +7 -7
- package/dist/browser/processors/obfProcessor.js +54 -47
- package/dist/browser/processors/opmlProcessor.js +6 -10
- package/dist/browser/processors/snap/helpers.js +34 -30
- package/dist/browser/processors/snapProcessor.js +28 -28
- package/dist/browser/processors/touchchatProcessor.js +24 -25
- package/dist/browser/utilities/analytics/history.js +24 -18
- package/dist/browser/utilities/analytics/metrics/comparison.js +16 -16
- package/dist/browser/utilities/analytics/metrics/vocabulary.js +2 -2
- package/dist/browser/utilities/analytics/reference/browser.js +16 -16
- package/dist/browser/utilities/analytics/reference/index.js +25 -24
- package/dist/browser/utils/io.js +29 -25
- package/dist/browser/utils/sqlite.js +5 -5
- package/dist/browser/utils/zip.js +2 -4
- package/dist/browser/validation/gridsetValidator.js +2 -2
- package/dist/browser/validation/obfValidator.js +2 -2
- package/dist/browser/validation/snapValidator.js +3 -3
- package/dist/browser/validation/touchChatValidator.js +3 -3
- package/dist/cli/index.js +19 -16
- package/dist/core/baseProcessor.d.ts +1 -1
- package/dist/processors/applePanelsProcessor.js +24 -24
- package/dist/processors/astericsGridProcessor.d.ts +4 -4
- package/dist/processors/astericsGridProcessor.js +22 -24
- package/dist/processors/dotProcessor.js +6 -10
- package/dist/processors/excelProcessor.d.ts +3 -3
- package/dist/processors/excelProcessor.js +10 -13
- package/dist/processors/gridset/helpers.d.ts +9 -9
- package/dist/processors/gridset/helpers.js +33 -30
- package/dist/processors/gridset/symbolExtractor.d.ts +1 -1
- package/dist/processors/gridset/symbolExtractor.js +2 -2
- package/dist/processors/gridset/symbolSearch.d.ts +10 -10
- package/dist/processors/gridset/symbolSearch.js +22 -22
- package/dist/processors/gridset/symbols.d.ts +3 -3
- package/dist/processors/gridset/symbols.js +14 -14
- package/dist/processors/gridsetProcessor.d.ts +2 -2
- package/dist/processors/gridsetProcessor.js +7 -7
- package/dist/processors/obfProcessor.d.ts +2 -2
- package/dist/processors/obfProcessor.js +54 -47
- package/dist/processors/obfsetProcessor.js +1 -2
- package/dist/processors/opmlProcessor.js +6 -10
- package/dist/processors/snap/helpers.d.ts +8 -8
- package/dist/processors/snap/helpers.js +34 -30
- package/dist/processors/snapProcessor.d.ts +2 -2
- package/dist/processors/snapProcessor.js +28 -28
- package/dist/processors/touchchatProcessor.d.ts +2 -2
- package/dist/processors/touchchatProcessor.js +24 -25
- package/dist/types/aac.d.ts +2 -2
- package/dist/utilities/analytics/history.d.ts +8 -8
- package/dist/utilities/analytics/history.js +24 -18
- package/dist/utilities/analytics/index.d.ts +1 -1
- package/dist/utilities/analytics/index.js +3 -2
- package/dist/utilities/analytics/metrics/comparison.d.ts +1 -1
- package/dist/utilities/analytics/metrics/comparison.js +16 -16
- package/dist/utilities/analytics/metrics/vocabulary.d.ts +1 -1
- package/dist/utilities/analytics/metrics/vocabulary.js +2 -2
- package/dist/utilities/analytics/reference/browser.d.ts +9 -9
- package/dist/utilities/analytics/reference/browser.js +16 -16
- package/dist/utilities/analytics/reference/index.d.ts +21 -21
- package/dist/utilities/analytics/reference/index.js +25 -24
- package/dist/utilities/symbolTools.d.ts +5 -5
- package/dist/utilities/symbolTools.js +10 -8
- package/dist/utils/io.d.ts +11 -11
- package/dist/utils/io.js +29 -25
- package/dist/utils/sqlite.d.ts +1 -1
- package/dist/utils/sqlite.js +5 -5
- package/dist/utils/zip.js +2 -4
- package/dist/validation/applePanelsValidator.js +7 -6
- package/dist/validation/astericsValidator.js +2 -2
- package/dist/validation/dotValidator.js +2 -2
- package/dist/validation/excelValidator.js +2 -2
- package/dist/validation/gridsetValidator.js +2 -2
- package/dist/validation/index.js +2 -2
- package/dist/validation/obfValidator.js +2 -2
- package/dist/validation/obfsetValidator.js +2 -2
- package/dist/validation/opmlValidator.js +2 -2
- package/dist/validation/snapValidator.js +3 -3
- package/dist/validation/touchChatValidator.js +3 -3
- package/docs/BROWSER_USAGE.md +0 -40
- package/package.json +1 -1
|
@@ -64,30 +64,30 @@ export declare function exportHistoryToBaton(entries: HistoryEntry[], options?:
|
|
|
64
64
|
/**
|
|
65
65
|
* Read Grid 3 phrase history from a history.sqlite database and tag entries with their source.
|
|
66
66
|
*/
|
|
67
|
-
export declare function readGrid3History(historyDbPath: string): HistoryEntry[]
|
|
67
|
+
export declare function readGrid3History(historyDbPath: string): Promise<HistoryEntry[]>;
|
|
68
68
|
/**
|
|
69
69
|
* Read Grid 3 history for a specific user/language combination.
|
|
70
70
|
*/
|
|
71
|
-
export declare function readGrid3HistoryForUser(userName: string, langCode?: string): HistoryEntry[]
|
|
71
|
+
export declare function readGrid3HistoryForUser(userName: string, langCode?: string): Promise<HistoryEntry[]>;
|
|
72
72
|
/**
|
|
73
73
|
* Read every available Grid 3 history database on the machine.
|
|
74
74
|
*/
|
|
75
|
-
export declare function readAllGrid3History(): HistoryEntry[]
|
|
75
|
+
export declare function readAllGrid3History(): Promise<HistoryEntry[]>;
|
|
76
76
|
/**
|
|
77
77
|
* Read Snap button usage from a pageset database and tag entries with source.
|
|
78
78
|
*/
|
|
79
|
-
export declare function readSnapUsage(pagesetPath: string): HistoryEntry[]
|
|
79
|
+
export declare function readSnapUsage(pagesetPath: string): Promise<HistoryEntry[]>;
|
|
80
80
|
/**
|
|
81
81
|
* Read Snap usage for a specific user across all discovered pagesets.
|
|
82
82
|
*/
|
|
83
|
-
export declare function readSnapUsageForUser(userId?: string, packageNamePattern?: string): HistoryEntry[]
|
|
84
|
-
export declare function listSnapUsers(): SnapUserInfo[]
|
|
83
|
+
export declare function readSnapUsageForUser(userId?: string, packageNamePattern?: string): Promise<HistoryEntry[]>;
|
|
84
|
+
export declare function listSnapUsers(): Promise<SnapUserInfo[]>;
|
|
85
85
|
/**
|
|
86
86
|
* List Grid 3 users on the current machine.
|
|
87
87
|
*/
|
|
88
|
-
export declare function listGrid3Users(): Grid3UserPath[]
|
|
88
|
+
export declare function listGrid3Users(): Promise<Grid3UserPath[]>;
|
|
89
89
|
/**
|
|
90
90
|
* Convenience helper to gather all available history across Grid 3 and Snap.
|
|
91
91
|
* Returns an empty array if no history files are present.
|
|
92
92
|
*/
|
|
93
|
-
export declare function collectUnifiedHistory(): HistoryEntry[]
|
|
93
|
+
export declare function collectUnifiedHistory(): Promise<HistoryEntry[]>;
|
|
@@ -72,8 +72,9 @@ function exportHistoryToBaton(entries, options) {
|
|
|
72
72
|
/**
|
|
73
73
|
* Read Grid 3 phrase history from a history.sqlite database and tag entries with their source.
|
|
74
74
|
*/
|
|
75
|
-
function readGrid3History(historyDbPath) {
|
|
76
|
-
|
|
75
|
+
async function readGrid3History(historyDbPath) {
|
|
76
|
+
const history = await (0, helpers_1.readGrid3History)(historyDbPath);
|
|
77
|
+
return history.map((e) => ({
|
|
77
78
|
...e,
|
|
78
79
|
source: 'Grid',
|
|
79
80
|
}));
|
|
@@ -81,8 +82,9 @@ function readGrid3History(historyDbPath) {
|
|
|
81
82
|
/**
|
|
82
83
|
* Read Grid 3 history for a specific user/language combination.
|
|
83
84
|
*/
|
|
84
|
-
function readGrid3HistoryForUser(userName, langCode) {
|
|
85
|
-
|
|
85
|
+
async function readGrid3HistoryForUser(userName, langCode) {
|
|
86
|
+
const history = await (0, helpers_1.readGrid3HistoryForUser)(userName, langCode);
|
|
87
|
+
return history.map((e) => ({
|
|
86
88
|
...e,
|
|
87
89
|
source: 'Grid',
|
|
88
90
|
}));
|
|
@@ -90,39 +92,43 @@ function readGrid3HistoryForUser(userName, langCode) {
|
|
|
90
92
|
/**
|
|
91
93
|
* Read every available Grid 3 history database on the machine.
|
|
92
94
|
*/
|
|
93
|
-
function readAllGrid3History() {
|
|
94
|
-
|
|
95
|
+
async function readAllGrid3History() {
|
|
96
|
+
const history = await (0, helpers_1.readAllGrid3History)();
|
|
97
|
+
return history.map((e) => ({ ...e, source: 'Grid' }));
|
|
95
98
|
}
|
|
96
99
|
/**
|
|
97
100
|
* Read Snap button usage from a pageset database and tag entries with source.
|
|
98
101
|
*/
|
|
99
|
-
function readSnapUsage(pagesetPath) {
|
|
100
|
-
|
|
102
|
+
async function readSnapUsage(pagesetPath) {
|
|
103
|
+
const usage = await (0, helpers_2.readSnapUsage)(pagesetPath);
|
|
104
|
+
return usage.map((e) => ({ ...e, source: 'Snap' }));
|
|
101
105
|
}
|
|
102
106
|
/**
|
|
103
107
|
* Read Snap usage for a specific user across all discovered pagesets.
|
|
104
108
|
*/
|
|
105
|
-
function readSnapUsageForUser(userId, packageNamePattern = 'TobiiDynavox') {
|
|
106
|
-
|
|
109
|
+
async function readSnapUsageForUser(userId, packageNamePattern = 'TobiiDynavox') {
|
|
110
|
+
const usage = await (0, helpers_2.readSnapUsageForUser)(userId, packageNamePattern);
|
|
111
|
+
return usage.map((e) => ({
|
|
107
112
|
...e,
|
|
108
113
|
source: 'Snap',
|
|
109
114
|
}));
|
|
110
115
|
}
|
|
111
|
-
function listSnapUsers() {
|
|
112
|
-
return (0, helpers_2.findSnapUsers)();
|
|
116
|
+
async function listSnapUsers() {
|
|
117
|
+
return await (0, helpers_2.findSnapUsers)();
|
|
113
118
|
}
|
|
114
119
|
/**
|
|
115
120
|
* List Grid 3 users on the current machine.
|
|
116
121
|
*/
|
|
117
|
-
function listGrid3Users() {
|
|
118
|
-
return (0, helpers_1.findGrid3Users)();
|
|
122
|
+
async function listGrid3Users() {
|
|
123
|
+
return await (0, helpers_1.findGrid3Users)();
|
|
119
124
|
}
|
|
120
125
|
/**
|
|
121
126
|
* Convenience helper to gather all available history across Grid 3 and Snap.
|
|
122
127
|
* Returns an empty array if no history files are present.
|
|
123
128
|
*/
|
|
124
|
-
function collectUnifiedHistory() {
|
|
125
|
-
const gridHistory = readAllGrid3History();
|
|
126
|
-
const
|
|
127
|
-
|
|
129
|
+
async function collectUnifiedHistory() {
|
|
130
|
+
const gridHistory = await readAllGrid3History();
|
|
131
|
+
const users = await (0, helpers_2.findSnapUsers)();
|
|
132
|
+
const snapHistory = await Promise.all(users.map(async (u) => await readSnapUsageForUser(u.userId)));
|
|
133
|
+
return [...gridHistory, ...snapHistory.flat()];
|
|
128
134
|
}
|
|
@@ -28,4 +28,4 @@ export declare function getReferenceDataPath(fileAdapter: FileAdapter): string;
|
|
|
28
28
|
/**
|
|
29
29
|
* Check if reference data files exist
|
|
30
30
|
*/
|
|
31
|
-
export declare function hasReferenceData(fileAdapter?: FileAdapter): boolean
|
|
31
|
+
export declare function hasReferenceData(fileAdapter?: FileAdapter): Promise<boolean>;
|
|
@@ -62,7 +62,7 @@ function getReferenceDataPath(fileAdapter) {
|
|
|
62
62
|
/**
|
|
63
63
|
* Check if reference data files exist
|
|
64
64
|
*/
|
|
65
|
-
function hasReferenceData(fileAdapter = io_1.defaultFileAdapter) {
|
|
65
|
+
async function hasReferenceData(fileAdapter = io_1.defaultFileAdapter) {
|
|
66
66
|
const { pathExists, join } = fileAdapter;
|
|
67
67
|
const dataPath = getReferenceDataPath(fileAdapter);
|
|
68
68
|
const requiredFiles = [
|
|
@@ -72,5 +72,6 @@ function hasReferenceData(fileAdapter = io_1.defaultFileAdapter) {
|
|
|
72
72
|
'synonyms.en.json',
|
|
73
73
|
'fringe.en.json',
|
|
74
74
|
];
|
|
75
|
-
|
|
75
|
+
const existingPaths = await Promise.all(requiredFiles.map(async (file) => await pathExists(join(dataPath, file))));
|
|
76
|
+
return existingPaths.every((exists) => exists);
|
|
76
77
|
}
|
|
@@ -19,7 +19,7 @@ export declare class ComparisonAnalyzer {
|
|
|
19
19
|
compare(targetResult: MetricsResult, compareResult: MetricsResult, options?: {
|
|
20
20
|
includeSentences?: boolean;
|
|
21
21
|
locale?: string;
|
|
22
|
-
} & Partial<MetricsOptions>): ComparisonResult
|
|
22
|
+
} & Partial<MetricsOptions>): Promise<ComparisonResult>;
|
|
23
23
|
/**
|
|
24
24
|
* Calculate CARE component scores
|
|
25
25
|
*/
|
|
@@ -26,7 +26,7 @@ class ComparisonAnalyzer {
|
|
|
26
26
|
/**
|
|
27
27
|
* Compare two board sets
|
|
28
28
|
*/
|
|
29
|
-
compare(targetResult, compareResult, options) {
|
|
29
|
+
async compare(targetResult, compareResult, options) {
|
|
30
30
|
// Create base result from target
|
|
31
31
|
const baseResult = { ...targetResult };
|
|
32
32
|
// Create word maps with normalized keys
|
|
@@ -80,7 +80,7 @@ class ComparisonAnalyzer {
|
|
|
80
80
|
};
|
|
81
81
|
});
|
|
82
82
|
// Calculate CARE components
|
|
83
|
-
const careComponents = this.calculateCareComponents(targetResult, compareResult, overlappingWords, options);
|
|
83
|
+
const careComponents = await this.calculateCareComponents(targetResult, compareResult, overlappingWords, options);
|
|
84
84
|
// Analyze high/low effort words
|
|
85
85
|
const highEffortWords = [];
|
|
86
86
|
const lowEffortWords = [];
|
|
@@ -113,7 +113,7 @@ class ComparisonAnalyzer {
|
|
|
113
113
|
// Sentence analysis
|
|
114
114
|
let sentences = [];
|
|
115
115
|
if (options?.includeSentences) {
|
|
116
|
-
const testSentences = this.referenceLoader.loadSentences();
|
|
116
|
+
const testSentences = await this.referenceLoader.loadSentences();
|
|
117
117
|
const targetSentences = this.sentenceAnalyzer.analyzeSentences(targetResult, testSentences);
|
|
118
118
|
const compareSentences = this.sentenceAnalyzer.analyzeSentences(compareResult, testSentences);
|
|
119
119
|
sentences = targetSentences.map((ts, idx) => ({
|
|
@@ -126,7 +126,7 @@ class ComparisonAnalyzer {
|
|
|
126
126
|
}));
|
|
127
127
|
}
|
|
128
128
|
// Core vocabulary analysis
|
|
129
|
-
const coreLists = this.referenceLoader.loadCoreLists();
|
|
129
|
+
const coreLists = await this.referenceLoader.loadCoreLists();
|
|
130
130
|
const cores = {};
|
|
131
131
|
coreLists.forEach((list) => {
|
|
132
132
|
let targetTotal = 0;
|
|
@@ -174,8 +174,8 @@ class ComparisonAnalyzer {
|
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
176
|
// Fringe vocabulary analysis
|
|
177
|
-
const fringeWords = this.analyzeFringe(targetWords, compareWords);
|
|
178
|
-
const commonFringeWords = this.analyzeCommonFringe(targetWords, compareWords);
|
|
177
|
+
const fringeWords = await this.analyzeFringe(targetWords, compareWords);
|
|
178
|
+
const commonFringeWords = await this.analyzeCommonFringe(targetWords, compareWords);
|
|
179
179
|
return {
|
|
180
180
|
...baseResult,
|
|
181
181
|
buttons: enrichedButtons,
|
|
@@ -217,9 +217,9 @@ class ComparisonAnalyzer {
|
|
|
217
217
|
/**
|
|
218
218
|
* Calculate CARE component scores
|
|
219
219
|
*/
|
|
220
|
-
calculateCareComponents(targetResult, compareResult, _overlappingWords, options) {
|
|
220
|
+
async calculateCareComponents(targetResult, compareResult, _overlappingWords, options) {
|
|
221
221
|
// Load common words with baseline efforts (matching Ruby line 527-534)
|
|
222
|
-
const commonWordsData = this.referenceLoader.loadCommonWords();
|
|
222
|
+
const commonWordsData = await this.referenceLoader.loadCommonWords();
|
|
223
223
|
const commonWords = new Map();
|
|
224
224
|
commonWordsData.words.forEach((word) => {
|
|
225
225
|
commonWords.set(word.toLowerCase(), commonWordsData.efforts[word] || 0);
|
|
@@ -271,10 +271,10 @@ class ComparisonAnalyzer {
|
|
|
271
271
|
}
|
|
272
272
|
});
|
|
273
273
|
// Load reference data
|
|
274
|
-
const coreLists = this.referenceLoader.loadCoreLists();
|
|
275
|
-
const fringe = this.referenceLoader.loadFringe();
|
|
276
|
-
const commonFringe = this.referenceLoader.loadCommonFringe();
|
|
277
|
-
const sentences = this.referenceLoader.loadSentences();
|
|
274
|
+
const coreLists = await this.referenceLoader.loadCoreLists();
|
|
275
|
+
const fringe = await this.referenceLoader.loadFringe();
|
|
276
|
+
const commonFringe = await this.referenceLoader.loadCommonFringe();
|
|
277
|
+
const sentences = await this.referenceLoader.loadSentences();
|
|
278
278
|
// Calculate core coverage and effort (matching Ruby lines 609-647)
|
|
279
279
|
let coreCount = 0;
|
|
280
280
|
let compCoreCount = 0;
|
|
@@ -426,8 +426,8 @@ class ComparisonAnalyzer {
|
|
|
426
426
|
/**
|
|
427
427
|
* Analyze fringe vocabulary
|
|
428
428
|
*/
|
|
429
|
-
analyzeFringe(targetWords, compareWords) {
|
|
430
|
-
const fringe = this.referenceLoader.loadFringe();
|
|
429
|
+
async analyzeFringe(targetWords, compareWords) {
|
|
430
|
+
const fringe = await this.referenceLoader.loadFringe();
|
|
431
431
|
const result = [];
|
|
432
432
|
fringe.forEach((word) => {
|
|
433
433
|
const key = this.normalize(word);
|
|
@@ -447,8 +447,8 @@ class ComparisonAnalyzer {
|
|
|
447
447
|
/**
|
|
448
448
|
* Analyze common fringe vocabulary
|
|
449
449
|
*/
|
|
450
|
-
analyzeCommonFringe(targetWords, compareWords) {
|
|
451
|
-
const fringe = this.referenceLoader.loadFringe();
|
|
450
|
+
async analyzeCommonFringe(targetWords, compareWords) {
|
|
451
|
+
const fringe = await this.referenceLoader.loadFringe();
|
|
452
452
|
const result = [];
|
|
453
453
|
fringe.forEach((word) => {
|
|
454
454
|
const key = this.normalize(word);
|
|
@@ -16,12 +16,12 @@ class VocabularyAnalyzer {
|
|
|
16
16
|
/**
|
|
17
17
|
* Analyze vocabulary coverage against core lists
|
|
18
18
|
*/
|
|
19
|
-
analyze(metrics, options) {
|
|
19
|
+
async analyze(metrics, options) {
|
|
20
20
|
// const locale = options?.locale || metrics.locale || 'en';
|
|
21
21
|
const highEffortThreshold = options?.highEffortThreshold || 5.0;
|
|
22
22
|
const lowEffortThreshold = options?.lowEffortThreshold || 2.0;
|
|
23
23
|
// Load reference data
|
|
24
|
-
const coreLists = this.referenceLoader.loadCoreLists();
|
|
24
|
+
const coreLists = await this.referenceLoader.loadCoreLists();
|
|
25
25
|
// Create word to effort map (using lowercase keys for matching)
|
|
26
26
|
const wordEffortMap = new Map();
|
|
27
27
|
metrics.buttons.forEach((btn) => {
|
|
@@ -16,16 +16,16 @@ export interface ReferenceData {
|
|
|
16
16
|
export declare class InMemoryReferenceLoader implements ReferenceDataProvider {
|
|
17
17
|
private data;
|
|
18
18
|
constructor(data: ReferenceData);
|
|
19
|
-
loadCoreLists(): CoreList[]
|
|
20
|
-
loadCommonWords(): CommonWordsData
|
|
21
|
-
loadSynonyms(): SynonymsData
|
|
22
|
-
loadSentences(): string[][]
|
|
23
|
-
loadFringe(): string[]
|
|
24
|
-
loadBaseWords(): {
|
|
19
|
+
loadCoreLists(): Promise<CoreList[]>;
|
|
20
|
+
loadCommonWords(): Promise<CommonWordsData>;
|
|
21
|
+
loadSynonyms(): Promise<SynonymsData>;
|
|
22
|
+
loadSentences(): Promise<string[][]>;
|
|
23
|
+
loadFringe(): Promise<string[]>;
|
|
24
|
+
loadBaseWords(): Promise<{
|
|
25
25
|
[word: string]: boolean;
|
|
26
|
-
}
|
|
27
|
-
loadCommonFringe(): string[]
|
|
28
|
-
loadAll(): ReferenceData
|
|
26
|
+
}>;
|
|
27
|
+
loadCommonFringe(): Promise<string[]>;
|
|
28
|
+
loadAll(): Promise<ReferenceData>;
|
|
29
29
|
}
|
|
30
30
|
export declare function loadReferenceDataFromUrl(baseUrl: string, locale?: string): Promise<ReferenceData>;
|
|
31
31
|
export declare function createBrowserReferenceLoader(baseUrl: string, locale?: string): Promise<InMemoryReferenceLoader>;
|
|
@@ -10,34 +10,34 @@ class InMemoryReferenceLoader {
|
|
|
10
10
|
constructor(data) {
|
|
11
11
|
this.data = data;
|
|
12
12
|
}
|
|
13
|
-
loadCoreLists() {
|
|
14
|
-
return this.data.coreLists;
|
|
13
|
+
async loadCoreLists() {
|
|
14
|
+
return Promise.resolve(this.data.coreLists);
|
|
15
15
|
}
|
|
16
|
-
loadCommonWords() {
|
|
17
|
-
return this.data.commonWords;
|
|
16
|
+
async loadCommonWords() {
|
|
17
|
+
return Promise.resolve(this.data.commonWords);
|
|
18
18
|
}
|
|
19
|
-
loadSynonyms() {
|
|
20
|
-
return this.data.synonyms;
|
|
19
|
+
async loadSynonyms() {
|
|
20
|
+
return Promise.resolve(this.data.synonyms);
|
|
21
21
|
}
|
|
22
|
-
loadSentences() {
|
|
23
|
-
return this.data.sentences;
|
|
22
|
+
async loadSentences() {
|
|
23
|
+
return Promise.resolve(this.data.sentences);
|
|
24
24
|
}
|
|
25
|
-
loadFringe() {
|
|
26
|
-
return this.data.fringe;
|
|
25
|
+
async loadFringe() {
|
|
26
|
+
return Promise.resolve(this.data.fringe);
|
|
27
27
|
}
|
|
28
|
-
loadBaseWords() {
|
|
29
|
-
return this.data.baseWords;
|
|
28
|
+
async loadBaseWords() {
|
|
29
|
+
return Promise.resolve(this.data.baseWords);
|
|
30
30
|
}
|
|
31
|
-
loadCommonFringe() {
|
|
31
|
+
async loadCommonFringe() {
|
|
32
32
|
const commonWords = new Set(this.data.commonWords.words.map((w) => w.toLowerCase()));
|
|
33
33
|
const coreWords = new Set();
|
|
34
34
|
this.data.coreLists.forEach((list) => {
|
|
35
35
|
list.words.forEach((word) => coreWords.add(word.toLowerCase()));
|
|
36
36
|
});
|
|
37
|
-
return Array.from(commonWords).filter((word) => !coreWords.has(word));
|
|
37
|
+
return Promise.resolve(Array.from(commonWords).filter((word) => !coreWords.has(word)));
|
|
38
38
|
}
|
|
39
|
-
loadAll() {
|
|
40
|
-
return this.data;
|
|
39
|
+
async loadAll() {
|
|
40
|
+
return Promise.resolve(this.data);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
exports.InMemoryReferenceLoader = InMemoryReferenceLoader;
|
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
import { CoreList, CommonWordsData, SynonymsData } from '../metrics/types';
|
|
8
8
|
import { FileAdapter } from '../../../utils/io';
|
|
9
9
|
export interface ReferenceDataProvider {
|
|
10
|
-
loadCoreLists(): CoreList[]
|
|
11
|
-
loadCommonWords(): CommonWordsData
|
|
12
|
-
loadSynonyms(): SynonymsData
|
|
13
|
-
loadSentences(): string[][]
|
|
14
|
-
loadFringe(): string[]
|
|
15
|
-
loadBaseWords(): {
|
|
10
|
+
loadCoreLists(): Promise<CoreList[]>;
|
|
11
|
+
loadCommonWords(): Promise<CommonWordsData>;
|
|
12
|
+
loadSynonyms(): Promise<SynonymsData>;
|
|
13
|
+
loadSentences(): Promise<string[][]>;
|
|
14
|
+
loadFringe(): Promise<string[]>;
|
|
15
|
+
loadBaseWords(): Promise<{
|
|
16
16
|
[word: string]: boolean;
|
|
17
|
-
}
|
|
18
|
-
loadCommonFringe(): string[]
|
|
19
|
-
loadAll(): {
|
|
17
|
+
}>;
|
|
18
|
+
loadCommonFringe(): Promise<string[]>;
|
|
19
|
+
loadAll(): Promise<{
|
|
20
20
|
coreLists: CoreList[];
|
|
21
21
|
commonWords: CommonWordsData;
|
|
22
22
|
synonyms: SynonymsData;
|
|
@@ -25,7 +25,7 @@ export interface ReferenceDataProvider {
|
|
|
25
25
|
baseWords: {
|
|
26
26
|
[word: string]: boolean;
|
|
27
27
|
};
|
|
28
|
-
}
|
|
28
|
+
}>;
|
|
29
29
|
}
|
|
30
30
|
export declare class ReferenceLoader {
|
|
31
31
|
private dataDir;
|
|
@@ -35,39 +35,39 @@ export declare class ReferenceLoader {
|
|
|
35
35
|
/**
|
|
36
36
|
* Load core vocabulary lists
|
|
37
37
|
*/
|
|
38
|
-
loadCoreLists(): CoreList[]
|
|
38
|
+
loadCoreLists(): Promise<CoreList[]>;
|
|
39
39
|
/**
|
|
40
40
|
* Load common words with baseline effort scores
|
|
41
41
|
*/
|
|
42
|
-
loadCommonWords(): CommonWordsData
|
|
42
|
+
loadCommonWords(): Promise<CommonWordsData>;
|
|
43
43
|
/**
|
|
44
44
|
* Load synonym mappings
|
|
45
45
|
*/
|
|
46
|
-
loadSynonyms(): SynonymsData
|
|
46
|
+
loadSynonyms(): Promise<SynonymsData>;
|
|
47
47
|
/**
|
|
48
48
|
* Load test sentences
|
|
49
49
|
*/
|
|
50
|
-
loadSentences(): string[][]
|
|
50
|
+
loadSentences(): Promise<string[][]>;
|
|
51
51
|
/**
|
|
52
52
|
* Load fringe vocabulary
|
|
53
53
|
*/
|
|
54
|
-
loadFringe(): string[]
|
|
54
|
+
loadFringe(): Promise<string[]>;
|
|
55
55
|
/**
|
|
56
56
|
* Load base words hash map
|
|
57
57
|
*/
|
|
58
|
-
loadBaseWords(): {
|
|
58
|
+
loadBaseWords(): Promise<{
|
|
59
59
|
[word: string]: boolean;
|
|
60
|
-
}
|
|
60
|
+
}>;
|
|
61
61
|
/**
|
|
62
62
|
* Load common fringe vocabulary
|
|
63
63
|
* Common words that are NOT in core vocabulary lists
|
|
64
64
|
* (matching Ruby loader.rb:413-420)
|
|
65
65
|
*/
|
|
66
|
-
loadCommonFringe(): string[]
|
|
66
|
+
loadCommonFringe(): Promise<string[]>;
|
|
67
67
|
/**
|
|
68
68
|
* Get all reference data at once
|
|
69
69
|
*/
|
|
70
|
-
loadAll(): {
|
|
70
|
+
loadAll(): Promise<{
|
|
71
71
|
coreLists: CoreList[];
|
|
72
72
|
commonWords: CommonWordsData;
|
|
73
73
|
synonyms: SynonymsData;
|
|
@@ -76,7 +76,7 @@ export declare class ReferenceLoader {
|
|
|
76
76
|
baseWords: {
|
|
77
77
|
[word: string]: boolean;
|
|
78
78
|
};
|
|
79
|
-
}
|
|
79
|
+
}>;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Get the default reference data path
|
|
@@ -85,4 +85,4 @@ export declare function getReferenceDataPath(fileAdapter?: FileAdapter): string;
|
|
|
85
85
|
/**
|
|
86
86
|
* Check if reference data files exist
|
|
87
87
|
*/
|
|
88
|
-
export declare function hasReferenceData(fileAdapter?: FileAdapter): boolean
|
|
88
|
+
export declare function hasReferenceData(fileAdapter?: FileAdapter): Promise<boolean>;
|
|
@@ -26,46 +26,46 @@ class ReferenceLoader {
|
|
|
26
26
|
/**
|
|
27
27
|
* Load core vocabulary lists
|
|
28
28
|
*/
|
|
29
|
-
loadCoreLists() {
|
|
29
|
+
async loadCoreLists() {
|
|
30
30
|
const { readTextFromInput } = this.fileAdapter;
|
|
31
31
|
const filePath = this.fileAdapter.join(this.dataDir, `core_lists.${this.locale}.json`);
|
|
32
|
-
const content = readTextFromInput(filePath);
|
|
32
|
+
const content = await readTextFromInput(filePath);
|
|
33
33
|
return JSON.parse(String(content));
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Load common words with baseline effort scores
|
|
37
37
|
*/
|
|
38
|
-
loadCommonWords() {
|
|
38
|
+
async loadCommonWords() {
|
|
39
39
|
const { readTextFromInput, join } = this.fileAdapter;
|
|
40
40
|
const filePath = join(this.dataDir, `common_words.${this.locale}.json`);
|
|
41
|
-
const content = readTextFromInput(filePath);
|
|
41
|
+
const content = await readTextFromInput(filePath);
|
|
42
42
|
return JSON.parse(String(content));
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Load synonym mappings
|
|
46
46
|
*/
|
|
47
|
-
loadSynonyms() {
|
|
47
|
+
async loadSynonyms() {
|
|
48
48
|
const { readTextFromInput, join } = this.fileAdapter;
|
|
49
49
|
const filePath = join(this.dataDir, `synonyms.${this.locale}.json`);
|
|
50
|
-
const content = readTextFromInput(filePath);
|
|
50
|
+
const content = await readTextFromInput(filePath);
|
|
51
51
|
return JSON.parse(String(content));
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Load test sentences
|
|
55
55
|
*/
|
|
56
|
-
loadSentences() {
|
|
56
|
+
async loadSentences() {
|
|
57
57
|
const { readTextFromInput, join } = this.fileAdapter;
|
|
58
58
|
const filePath = join(this.dataDir, `sentences.${this.locale}.json`);
|
|
59
|
-
const content = readTextFromInput(filePath);
|
|
59
|
+
const content = await readTextFromInput(filePath);
|
|
60
60
|
return JSON.parse(String(content));
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Load fringe vocabulary
|
|
64
64
|
*/
|
|
65
|
-
loadFringe() {
|
|
65
|
+
async loadFringe() {
|
|
66
66
|
const { readTextFromInput, join } = this.fileAdapter;
|
|
67
67
|
const filePath = join(this.dataDir, `fringe.${this.locale}.json`);
|
|
68
|
-
const content = readTextFromInput(filePath);
|
|
68
|
+
const content = await readTextFromInput(filePath);
|
|
69
69
|
const data = JSON.parse(String(content));
|
|
70
70
|
// Flatten nested category words if needed
|
|
71
71
|
if (Array.isArray(data) && data.length > 0 && data[0].categories) {
|
|
@@ -82,10 +82,10 @@ class ReferenceLoader {
|
|
|
82
82
|
/**
|
|
83
83
|
* Load base words hash map
|
|
84
84
|
*/
|
|
85
|
-
loadBaseWords() {
|
|
85
|
+
async loadBaseWords() {
|
|
86
86
|
const { readTextFromInput, join } = this.fileAdapter;
|
|
87
87
|
const filePath = join(this.dataDir, `base_words.${this.locale}.json`);
|
|
88
|
-
const content = readTextFromInput(filePath);
|
|
88
|
+
const content = await readTextFromInput(filePath);
|
|
89
89
|
return JSON.parse(String(content));
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -93,10 +93,10 @@ class ReferenceLoader {
|
|
|
93
93
|
* Common words that are NOT in core vocabulary lists
|
|
94
94
|
* (matching Ruby loader.rb:413-420)
|
|
95
95
|
*/
|
|
96
|
-
loadCommonFringe() {
|
|
97
|
-
const commonWordsData = this.loadCommonWords();
|
|
96
|
+
async loadCommonFringe() {
|
|
97
|
+
const commonWordsData = await this.loadCommonWords();
|
|
98
98
|
const commonWords = new Set(commonWordsData.words.map((w) => w.toLowerCase()));
|
|
99
|
-
const coreLists = this.loadCoreLists();
|
|
99
|
+
const coreLists = await this.loadCoreLists();
|
|
100
100
|
const coreWords = new Set();
|
|
101
101
|
coreLists.forEach((list) => {
|
|
102
102
|
list.words.forEach((word) => coreWords.add(word.toLowerCase()));
|
|
@@ -108,14 +108,14 @@ class ReferenceLoader {
|
|
|
108
108
|
/**
|
|
109
109
|
* Get all reference data at once
|
|
110
110
|
*/
|
|
111
|
-
loadAll() {
|
|
111
|
+
async loadAll() {
|
|
112
112
|
return {
|
|
113
|
-
coreLists: this.loadCoreLists(),
|
|
114
|
-
commonWords: this.loadCommonWords(),
|
|
115
|
-
synonyms: this.loadSynonyms(),
|
|
116
|
-
sentences: this.loadSentences(),
|
|
117
|
-
fringe: this.loadFringe(),
|
|
118
|
-
baseWords: this.loadBaseWords(),
|
|
113
|
+
coreLists: await this.loadCoreLists(),
|
|
114
|
+
commonWords: await this.loadCommonWords(),
|
|
115
|
+
synonyms: await this.loadSynonyms(),
|
|
116
|
+
sentences: await this.loadSentences(),
|
|
117
|
+
fringe: await this.loadFringe(),
|
|
118
|
+
baseWords: await this.loadBaseWords(),
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -129,7 +129,7 @@ function getReferenceDataPath(fileAdapter = io_1.defaultFileAdapter) {
|
|
|
129
129
|
/**
|
|
130
130
|
* Check if reference data files exist
|
|
131
131
|
*/
|
|
132
|
-
function hasReferenceData(fileAdapter = io_1.defaultFileAdapter) {
|
|
132
|
+
async function hasReferenceData(fileAdapter = io_1.defaultFileAdapter) {
|
|
133
133
|
const { pathExists, join } = fileAdapter;
|
|
134
134
|
const dataPath = getReferenceDataPath();
|
|
135
135
|
const requiredFiles = [
|
|
@@ -139,5 +139,6 @@ function hasReferenceData(fileAdapter = io_1.defaultFileAdapter) {
|
|
|
139
139
|
'synonyms.en.json',
|
|
140
140
|
'fringe.en.json',
|
|
141
141
|
];
|
|
142
|
-
|
|
142
|
+
const existingPaths = await Promise.all(requiredFiles.map(async (file) => await pathExists(join(dataPath, file))));
|
|
143
|
+
return existingPaths.every((exists) => exists);
|
|
143
144
|
}
|
|
@@ -7,24 +7,24 @@ export declare abstract class SymbolResolver {
|
|
|
7
7
|
protected dbPath: string;
|
|
8
8
|
protected fileAdapter: FileAdapter;
|
|
9
9
|
constructor(symbolPath: string, dbPath: string, fileAdapter?: FileAdapter);
|
|
10
|
-
abstract resolveSymbol(symbolRef: string): string | null
|
|
10
|
+
abstract resolveSymbol(symbolRef: string): Promise<string | null>;
|
|
11
11
|
}
|
|
12
12
|
export declare class SnapSymbolExtractor extends SymbolExtractor {
|
|
13
13
|
getSymbolReferences(filePath: string): string[];
|
|
14
14
|
}
|
|
15
15
|
export declare class SnapSymbolResolver extends SymbolResolver {
|
|
16
|
-
resolveSymbol(symbolRef: string): string | null
|
|
16
|
+
resolveSymbol(symbolRef: string): Promise<string | null>;
|
|
17
17
|
}
|
|
18
18
|
export declare class Grid3SymbolExtractor extends SymbolExtractor {
|
|
19
19
|
getSymbolReferences(filePath: string): string[];
|
|
20
20
|
}
|
|
21
21
|
export declare class Grid3SymbolResolver extends SymbolResolver {
|
|
22
|
-
resolveSymbol(symbolRef: string): string | null
|
|
22
|
+
resolveSymbol(symbolRef: string): Promise<string | null>;
|
|
23
23
|
}
|
|
24
24
|
export declare class TouchChatSymbolExtractor extends SymbolExtractor {
|
|
25
25
|
getSymbolReferences(_filePath: string): string[];
|
|
26
26
|
}
|
|
27
27
|
export declare class TouchChatSymbolResolver extends SymbolResolver {
|
|
28
|
-
resolveSymbol(symbolRef: string): string | null
|
|
28
|
+
resolveSymbol(symbolRef: string): Promise<string | null>;
|
|
29
29
|
}
|
|
30
|
-
export declare function resolveSymbol(label: string, symbolDir: string, fileAdapter?: FileAdapter): string | null
|
|
30
|
+
export declare function resolveSymbol(label: string, symbolDir: string, fileAdapter?: FileAdapter): Promise<string | null>;
|