-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deinflect): Add logic to handle all inflections of the copula だ (#…
…988) - Adds a new type of deinflection for the copula, だ. - Adds mappings for all common conjugations to deinflect.dat. - See http://www.japaneseprofessor.com/reference/grammar/conjugations-of-the-japanese-copula/ - For handling polite negative じゃないです update general adjective handling to recognize polite です addition. Fixes #89
- Loading branch information
Showing
5 changed files
with
174 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Config } from '../configuration'; | ||
import { RcxDict } from '../data'; | ||
import { expect, use } from '@esm-bundle/chai'; | ||
import chaiLike from 'chai-like'; | ||
import chaiThings from 'chai-things'; | ||
import sinonChrome from 'sinon-chrome'; | ||
|
||
// Extend chai-like to allow using regex for fuzzy string matching inside | ||
// objects. | ||
chaiLike.extend({ | ||
match: function (object, expected) { | ||
return typeof object === 'string' && expected instanceof RegExp; | ||
}, | ||
assert: function (object, expected) { | ||
return expected instanceof RegExp && expected.test(object); | ||
}, | ||
}); | ||
|
||
use(chaiLike); | ||
use(chaiThings); | ||
|
||
let rcxDict: RcxDict; | ||
|
||
describe('data.ts', function () { | ||
// Increase timeout from 2000ms since data tests can take longer. | ||
// Make it relative to current timeout so config level changes are taken | ||
// into account. (ie browserstack) | ||
this.timeout(this.timeout() * 2); | ||
before(async function () { | ||
// stub sinon chrome getURL method to return the path it's given | ||
// Required to load dictionary files. | ||
sinonChrome.extension.getURL.returnsArg(0); | ||
rcxDict = await RcxDict.create({} as Config); | ||
}); | ||
|
||
describe('deinflect', function () { | ||
it('should include deinflections of length one or more', function () { | ||
expect(rcxDict.deinflect('です')).to.include.something.like({ | ||
word: 'だ', | ||
}); | ||
}); | ||
|
||
it('should not include empty deinflections', function () { | ||
expect(rcxDict.deinflect('な')).to.not.include.something.like({ | ||
word: '', | ||
}); | ||
}); | ||
}); | ||
|
||
describe('wordSearch', function () { | ||
it('should return results for deinflected copula', function () { | ||
expect( | ||
rcxDict.wordSearch('です', /* doNames= */ false)?.data | ||
).to.include.something.like({ | ||
entry: /^だ .*/, | ||
reason: '< polite', | ||
}); | ||
}); | ||
|
||
it('should not include copula deinflections for non-copula words', function () { | ||
expect( | ||
rcxDict.wordSearch('ぼんです', /* doNames= */ false)?.data | ||
).to.not.include.something.like({ entry: /^凡打 .*/ }); | ||
}); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters