Debian Codegraph @

bindings/node.js/src/test/spec.coffee

raw
1 describe 'Link Grammar Tests', ->
2
3 LinkGrammar = require __dirname + '/../../build/index.js'
4 require 'should'
5
6 linkGrammar = new LinkGrammar()
7
8 linkage = linkGrammar.parse 'turn off the light'
9
10 it 'should parse', ->
11 temp = linkGrammar.parse('do not be wise in your own estimation.')
12 temp.links.length.should.equal 11
13
14 it 'should handle null links', ->
15 temp = linkGrammar.parse('do not be foobar wise in your own estimation.')
16 temp.links.length.should.equal 11
17
18 # it 'should not crash', ->
19 # (-> linkGrammar.parse('crap crap crap crap crap')).should.throw('No links found')
20
21 it 'should have the correct number of links', ->
22 linkage.links[2].left.word.should.equal 'turn'
23 linkage.links.length.should.equal 5
24
25 it 'should have word list', ->
26 linkage.words.length.should.equal 6
27
28 it 'should get link list by label', ->
29 linkage.linksByLabel('MV').length.should.equal 1
30 linkage.linksByLabel(/J/).length.should.equal 1
31
32 it 'should get connector words', ->
33 connectors = linkage.getConnectorWords 'off'
34 connectors[0].source.label.should.equal 'MVp'
35 connectors[0].target.label.should.equal 'MV'
36 connectors[0].target.word.should.equal 'turn'
37 connectors[0].target.type.should.equal 'v'
38 connectors[1].source.label.should.equal 'J'
39 connectors[1].target.label.should.equal 'Js'
40 connectors[1].target.word.should.equal 'light'
41 connectors[1].target.type.should.equal 's'