<commit_before>/*
 * Copyright 2016 <NAME> Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy of the License at
 *      
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the License.
 */

'use strict'

describe('Parse lexicon', function() {
  
  var GrammarLexicon = require(__dirname+'/../lib/grammar-lexicon')
  
  describe('Creation: should fail with improper params', function() {
    it('',function() {
      expect(function() { 
        new GrammarLexicon(null)
      }).toThrowError('lexicon should not be null')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon()
      }).toThrowError('lexicon should be an object, not: undefined')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon(undefined)
      }).toThrowError('lexicon should be an object, not: undefined')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon(42)
      }).toThrowError('lexicon should be an object, not: 42')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon('plop')
      }).toThrowError('lexicon should be an object, not: "plop"')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon([])
      }).toThrowError('lexicon should be an object, not: []')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon({})
      }).toThrowError('lexicon should not be an empty object: {}')
    })
  })

  describe('', function() {
    var l = {
          STA: {
            verbal: 've, ves',
            irregular: {
              PFV: 'vil'
            }
          },
          ACT: {
            verbal: 'ma'
          },
          THE: {
            verbal: 'shu, shus',
            irregular: {
              'SPL.ATTR': 'shin',
              'SPL.NEG.ATTR': 'shushia'
            }
          },
          ITGa: {
            nominal: 'ne, nedh',
            meaning: 'who'
          },
          ITGi: {
            nominal: 'cul',
            compose: [ 'C-ul' ]
          },
          one: {
            verbal: 'ish'
          },
          two: {
            verbal: 'then'
          },
          ten: {
            verbal: 'farl',
            compose: [ 'farli-C', 'C-arli-C', 'C-arl' ]
          }
        }
      , gl = new GrammarLexicon(l)
      , Entry = GrammarLexicon.Entry
    
    it('', function() {
      var actual = gl.find('ACT')
        , expected = Entry('ACT',{ verbal: 'ma' })
      expect(actual).toEqual(expected)
      expect(actual.paradigm).toEqual('verbal')
      expect(actual.parts).toEqual(['ma'])
    })
    
    it('', function() {
      var actual = gl.find('STA')
        , expected = Entry('STA',{ verbal: 've, ves', irregular: { PFV: 'vil' } })
      expect(actual).toEqual(expected)
      expect(actual.paradigm).toEqual('verbal')
      expect(actual.parts).toEqual(['ve', 'ves'])
      expect(actual.irregular).toEqual({ PFV: 'vil' })
    })
  })
})<commit_msg>add test for retrieve compose field of lexicon entries<commit_after>/*
 * Copyright 2016 <NAME> Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy of the License at
 *      
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the License.
 */

'use strict'

describe('Parse lexicon', function() {
  
  var GrammarLexicon = require(__dirname+'/../lib/grammar-lexicon')
  
  describe('Creation: should fail with improper params', function() {
    it('',function() {
      expect(function() { 
        new GrammarLexicon(null)
      }).toThrowError('lexicon should not be null')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon()
      }).toThrowError('lexicon should be an object, not: undefined')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon(undefined)
      }).toThrowError('lexicon should be an object, not: undefined')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon(42)
      }).toThrowError('lexicon should be an object, not: 42')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon('plop')
      }).toThrowError('lexicon should be an object, not: "plop"')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon([])
      }).toThrowError('lexicon should be an object, not: []')
    })
    it('',function() {
      expect(function() { 
        new GrammarLexicon({})
      }).toThrowError('lexicon should not be an empty object: {}')
    })
  })

  describe('', function() {
    var l = {
          STA: {
            verbal: 've, ves',
            irregular: {
              PFV: 'vil'
            }
          },
          ACT: {
            verbal: 'ma'
          },
          THE: {
            verbal: 'shu, shus',
            irregular: {
              'SPL.ATTR': 'shin',
              'SPL.NEG.ATTR': 'shushia'
            }
          },
          ITGa: {
            nominal: 'ne, nedh',
            meaning: 'who'
          },
          ITGi: {
            nominal: 'cul',
            compose: [ 'C-ul' ]
          },
          one: {
            verbal: 'ish'
          },
          two: {
            verbal: 'then'
          },
          ten: {
            verbal: 'farl',
            compose: [ 'farli-C', 'C-arli-C', 'C-arl' ]
          }
        }
      , gl = new GrammarLexicon(l)
      , Entry = GrammarLexicon.Entry

    it('', function() {
      var actual = gl.find('ACT')
        , expected = Entry('ACT',{ verbal: 'ma' })
      expect(actual).toEqual(expected)
      expect(actual.paradigm).toEqual('verbal')
      expect(actual.parts).toEqual(['ma'])
    })

    it('', function() {
      var actual = gl.find('STA')
        , expected = Entry('STA',{ verbal: 've, ves', irregular: { PFV: 'vil' } })
      expect(actual).toEqual(expected)
      expect(actual.paradigm).toEqual('verbal')
      expect(actual.parts).toEqual(['ve', 'ves'])
      expect(actual.irregular).toEqual({ PFV: 'vil' })
    })

    it('', function() {
      var actual = gl.find('ten')
        , expected = Entry('ten',{ verbal: 'farl', compose: [ 'farli-C', 'C-arli-C', 'C-arl' ] })
      expect(actual).toEqual(expected)
      expect(actual.paradigm).toEqual('verbal')
      expect(actual.parts).toEqual(['farl'])
      expect(actual.compose).toEqual([ 'farli-C', 'C-arli-C', 'C-arl' ])
    })
  })
})
{'fraction_non_alphanumeric': 0.15244755244755245, 'fraction_numerical': 0.0033566433566433566, 'mean_word_length': 2.041684389621438, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2949324', 'n_tokens_mistral': 2216, 'n_tokens_neox': 2114, 'n_words': 538}