@nlpjs/lang-ko
Advanced tools
Comparing version 4.1.4 to 4.2.1
{ | ||
"name": "@nlpjs/lang-ko", | ||
"version": "4.1.4", | ||
"version": "4.2.1", | ||
"description": "Core", | ||
@@ -30,3 +30,3 @@ "author": { | ||
}, | ||
"gitHead": "99500ae2f3e16666fa5cc08a486664ef5267e810" | ||
"gitHead": "96ade95b2be5b659a2271d975ca8acdc5b2ed19e" | ||
} |
@@ -30,2 +30,3 @@ /* | ||
const names = {}; | ||
let initialized = false; | ||
@@ -63,8 +64,14 @@ function build() { | ||
build(); | ||
buildNames(); | ||
function initDicts() { | ||
if (!initialized) { | ||
build(); | ||
buildNames(); | ||
initialized = true; | ||
} | ||
} | ||
module.exports = { | ||
initDicts, | ||
dictionary, | ||
names, | ||
}; |
@@ -25,5 +25,6 @@ /* | ||
const { decomposeHangul, codaMap, composeHangul } = require('./hangul'); | ||
const { names } = require('./korean-dictionary'); | ||
const { initDicts, names } = require('./korean-dictionary'); | ||
function isName(word) { | ||
initDicts(); | ||
if (names.Full[word] || names.Given[word]) { | ||
@@ -30,0 +31,0 @@ return true; |
@@ -25,3 +25,3 @@ /* | ||
const { chunk } = require('./korean-chunker'); | ||
const { dictionary } = require('./korean-dictionary'); | ||
const { initDicts, dictionary } = require('./korean-dictionary'); | ||
@@ -35,2 +35,3 @@ const { | ||
function getTopSlice(word) { | ||
initDicts(); | ||
const max = Math.min(word.length, 2); | ||
@@ -87,2 +88,3 @@ for (let i = max; i > 1; i -= 1) { | ||
function stemWord(token) { | ||
initDicts(); | ||
const value = dictionary[token]; | ||
@@ -89,0 +91,0 @@ if (value) { |
@@ -26,3 +26,3 @@ /* | ||
const { tokenize, stemWord } = require('./korean-tokenizer'); | ||
const { dictionary } = require('./korean-dictionary'); | ||
const { initDicts, dictionary } = require('./korean-dictionary'); | ||
const TokenizerKo = require('./tokenizer-ko'); | ||
@@ -150,2 +150,3 @@ const NormalizerKo = require('./normalizer-ko'); | ||
innerStem() { | ||
initDicts(); | ||
const word = this.getCurrent(); | ||
@@ -158,2 +159,3 @@ const token = stemWord(this.prestem(word.trim())); | ||
async stem(text, input) { | ||
initDicts(); | ||
const inputText = | ||
@@ -191,2 +193,3 @@ typeof text === 'string' ? text : input.utterance || input.text; | ||
tokenizeAndStem(text) { | ||
initDicts(); | ||
const newText = this.tokenize(this.normalize(text)).join(' '); | ||
@@ -193,0 +196,0 @@ const tokens = tokenize(this.normalize(newText)) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2969645
1353