analyze-desumasu-dearu
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -14,3 +14,3 @@ // LICENSE : MIT | ||
var getTokenizer = require("kuromojin").getTokenizer; | ||
var tokenize = require("kuromojin").tokenize; | ||
/** | ||
@@ -26,6 +26,3 @@ * token object | ||
*/ | ||
// Cache tokens | ||
var _tokensCacheMap = {}; | ||
/** | ||
@@ -36,2 +33,3 @@ * デフォルトのオプション値 | ||
var defaultOptions = { | ||
@@ -190,5 +188,3 @@ // 接続的な "である" を無視する | ||
var ignoreConjunction = options.ignoreConjunction !== undefined ? options.ignoreConjunction : defaultOptions.ignoreConjunction; | ||
return getTokenizer().then(function (tokenizer) { | ||
var tokens = _tokensCacheMap[text] ? _tokensCacheMap[text] : tokenizer.tokenizeForSentence(text); | ||
_tokensCacheMap[text] = tokens; | ||
return tokenize(text).then(function (tokens) { | ||
var filterByType = tokens.filter(function (token, index) { | ||
@@ -195,0 +191,0 @@ var nextToken = tokens[index + 1]; // token[特殊・ダ] + nextToken[アル] なら 常体(である調) として認識する |
@@ -14,3 +14,3 @@ { | ||
}, | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "文の敬体(ですます調)、常体(である調)を解析", | ||
@@ -32,3 +32,3 @@ "main": "lib/analyze.js", | ||
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", | ||
"prepare": "git config --local core.hooksPath .githook" | ||
"prepare": "git config --local core.hooksPath .githooks" | ||
}, | ||
@@ -35,0 +35,0 @@ "keywords": [ |
// LICENSE : MIT | ||
"use strict"; | ||
const getTokenizer = require("kuromojin").getTokenizer; | ||
const tokenize = require("kuromojin").tokenize; | ||
/** | ||
@@ -15,4 +15,2 @@ * token object | ||
// Cache tokens | ||
const _tokensCacheMap = {}; | ||
/** | ||
@@ -148,5 +146,3 @@ * デフォルトのオプション値 | ||
options.ignoreConjunction !== undefined ? options.ignoreConjunction : defaultOptions.ignoreConjunction; | ||
return getTokenizer().then((tokenizer) => { | ||
const tokens = _tokensCacheMap[text] ? _tokensCacheMap[text] : tokenizer.tokenizeForSentence(text); | ||
_tokensCacheMap[text] = tokens; | ||
return tokenize(text).then((tokens) => { | ||
const filterByType = tokens.filter((token, index) => { | ||
@@ -153,0 +149,0 @@ const nextToken = tokens[index + 1]; |
Sorry, the diff of this file is not supported yet
35639
395