mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-11 13:59:31 -06:00
Implement categoryProbability, functionProbability, functionIsConstructor, functionsByCategory
This commit is contained in:
@@ -160,4 +160,49 @@ describe('abstract syntax', () => {
|
||||
test('functions', () => {
|
||||
expect(gr.getFunctions()).toEqual(['c','ind','s','z'])
|
||||
})
|
||||
|
||||
describe('function is constructor', () => {
|
||||
test('s', () => {
|
||||
expect(gr.functionIsConstructor('s')).toBe(true)
|
||||
})
|
||||
test('z', () => {
|
||||
expect(gr.functionIsConstructor('z')).toBe(true)
|
||||
})
|
||||
test('c', () => {
|
||||
expect(gr.functionIsConstructor('c')).toBe(true)
|
||||
})
|
||||
test('ind', () => {
|
||||
expect(gr.functionIsConstructor('ind')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('functions by category', () => {
|
||||
test('N', () => {
|
||||
expect(gr.functionsByCategory('N')).toEqual(['s','z'])
|
||||
})
|
||||
test('S', () => {
|
||||
expect(gr.functionsByCategory('S')).toEqual(['c'])
|
||||
})
|
||||
test('X', () => {
|
||||
expect(gr.functionsByCategory('X')).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('probabilities', () => {
|
||||
test.skip('category existing', () => {
|
||||
expect(gr.categoryProbability('S')).toBeDefined()
|
||||
})
|
||||
|
||||
test('category non-existent', () => {
|
||||
expect(gr.categoryProbability('NP')).toBeUndefined()
|
||||
})
|
||||
|
||||
test('function existing', () => {
|
||||
expect(gr.functionProbability('c')).toBeDefined() // returns -0 (!)
|
||||
})
|
||||
|
||||
test('function non-existent', () => {
|
||||
expect(gr.functionProbability('mkC')).toBeUndefined()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user