Skip to content

Commit eb333e7

Browse files
authored
Allow for extension of lexicon (#701)
1 parent 59a5fe5 commit eb333e7

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lib/natural/brill_pos_tagger/lib/Lexicon.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,20 @@ const dutchLexicon = require('../data/Dutch/brill_Lexicon.json')
2424
const DEBUG = false
2525

2626
// Constructor creates a Lexicon for language
27-
function Lexicon (language, defaultCategory, defaultCategoryCapitalised) {
28-
switch (language) {
29-
case 'EN':
30-
this.lexicon = englishLexicon
31-
break
32-
case 'DU':
33-
this.lexicon = dutchLexicon
34-
break
35-
default:
36-
this.lexicon = dutchLexicon
37-
break
38-
}
27+
function Lexicon (language, defaultCategory, defaultCategoryCapitalised, extendedLexicon) {
28+
const lexicon = (() => {
29+
switch (language) {
30+
case 'EN':
31+
return englishLexicon
32+
case 'DU':
33+
return dutchLexicon
34+
default:
35+
return dutchLexicon
36+
}
37+
})()
38+
39+
this.lexicon = Object.assign(lexicon, extendedLexicon || {})
40+
3941
if (defaultCategory) {
4042
this.defaultCategory = defaultCategory
4143
if (defaultCategoryCapitalised) {

0 commit comments

Comments
 (0)