Skip to content

Commit 94b879e

Browse files
committed
fix bug
1 parent 73c06af commit 94b879e

2 files changed

Lines changed: 11 additions & 27 deletions

File tree

src/utilities/analytics/morphology/engine.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,13 @@ export class MorphologyEngine {
2121
}
2222

2323
static fromGrid3Verbs(verbForms: Grid3VerbForms): MorphologyEngine {
24-
const engine = new MorphologyEngine({
25-
locale: verbForms.locale,
26-
version: 1,
27-
irregular: {},
28-
regular: {},
29-
});
24+
const engine = new MorphologyEngine(verbForms.locale.replace('_', '-'));
3025
engine.grid3Verbs = verbForms.verbs;
3126
return engine;
3227
}
3328

3429
static fromTDSnapLexicon(lexiconData: TDSnapLexiconData): MorphologyEngine {
35-
const engine = new MorphologyEngine({
36-
locale: lexiconData.locale,
37-
version: 1,
38-
irregular: {},
39-
regular: {},
40-
});
30+
const engine = new MorphologyEngine(lexiconData.locale.replace('_', '-'));
4131
engine.tdsnapLexicon = lexiconData;
4232
return engine;
4333
}

test/grammarGating.test.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,29 +101,23 @@ describe('Grammar Gating', () => {
101101
expect(forms).toContain('having');
102102
});
103103

104-
test('returns empty for words not in the verb map when no built-in rules', () => {
104+
test('returns built-in forms for words not in the verb map', () => {
105105
const forms = engine.inflect('walk', 'Verb');
106-
expect(forms).toEqual([]);
107-
});
108-
109-
test('returns empty for non-verb words when no built-in rules', () => {
110-
const forms = engine.inflect('child', 'Noun');
111-
expect(forms).toEqual([]);
112-
});
113-
114-
test('standalone engine with built-in rules inflects walk', () => {
115-
const builtin = new MorphologyEngine('en-gb');
116-
const forms = builtin.inflect('walk', 'Verb');
117106
expect(forms).toContain('walks');
118107
expect(forms).toContain('walked');
119108
expect(forms).toContain('walking');
120109
});
121110

122-
test('standalone engine with built-in rules inflects child', () => {
123-
const builtin = new MorphologyEngine('en-gb');
124-
const forms = builtin.inflect('child', 'Noun');
111+
test('returns built-in forms for non-verb words', () => {
112+
const forms = engine.inflect('child', 'Noun');
125113
expect(forms).toContain('children');
126114
});
115+
116+
test('prefers verb map forms over built-in rules for map verbs', () => {
117+
const forms = engine.inflect('drink', 'Verb');
118+
expect(forms).toContain('drunk');
119+
expect(forms).toContain('drank');
120+
});
127121
});
128122

129123
describe('{gerund} Placeholder Filtering', () => {

0 commit comments

Comments
 (0)