morpheme-match
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -29,3 +29,4 @@ // LICENSE : MIT | ||
var matchTokens = []; | ||
return function (token) { | ||
var matchSkipped = []; | ||
return function (token, index) { | ||
while (currentTokenPosition < tokenCount) { | ||
@@ -35,2 +36,3 @@ var expectedToken = matchedTokens[currentTokenPosition]; | ||
matchTokens.push(token); | ||
matchSkipped.push(false); | ||
currentTokenPosition += 1; | ||
@@ -40,5 +42,7 @@ break; | ||
currentTokenPosition += 1; | ||
matchSkipped.push(true); | ||
} else { | ||
// reset position | ||
matchTokens.length = 0; | ||
matchSkipped.length = 0; | ||
currentTokenPosition = 0; | ||
@@ -51,8 +55,11 @@ break; | ||
var tokens = matchTokens.slice(); | ||
var skipped = matchSkipped.slice(); | ||
// match -> reset | ||
currentTokenPosition = 0; | ||
matchTokens.length = 0; | ||
matchSkipped.length = 0; | ||
return { | ||
match: true, | ||
tokens: tokens | ||
tokens: tokens, | ||
skipped: skipped | ||
}; | ||
@@ -59,0 +66,0 @@ } |
@@ -18,3 +18,3 @@ { | ||
], | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"main": "lib/morpheme-match.js", | ||
@@ -21,0 +21,0 @@ "directories": { |
@@ -23,3 +23,3 @@ # morpheme-match [![Build Status](https://travis-ci.org/azu/morpheme-match.svg?branch=master)](https://travis-ci.org/azu/morpheme-match) | ||
`createTokenMatcher()` return `function(token): { match: boolean, tokens?: Array }`. | ||
`createTokenMatcher()` return `function(token): { match: boolean, tokens?: Array, skipped? Array }`. | ||
@@ -111,3 +111,3 @@ We want to check "名詞かもしれない" contain "かも" token. | ||
const result = tokens.some(token => { | ||
const {match, tokens} = expectToken(token); | ||
const {match, tokens, skipped} = expectToken(token); | ||
resultTokens = tokens; | ||
@@ -114,0 +114,0 @@ return match; |
@@ -28,3 +28,4 @@ // LICENSE : MIT | ||
const matchTokens = []; | ||
return (token) => { | ||
const matchSkipped = []; | ||
return (token, index) => { | ||
while (currentTokenPosition < tokenCount) { | ||
@@ -34,2 +35,3 @@ const expectedToken = matchedTokens[currentTokenPosition]; | ||
matchTokens.push(token); | ||
matchSkipped.push(false); | ||
currentTokenPosition += 1; | ||
@@ -39,5 +41,7 @@ break; | ||
currentTokenPosition += 1; | ||
matchSkipped.push(true); | ||
} else { | ||
// reset position | ||
matchTokens.length = 0; | ||
matchSkipped.length = 0; | ||
currentTokenPosition = 0; | ||
@@ -50,8 +54,11 @@ break; | ||
const tokens = matchTokens.slice(); | ||
const skipped = matchSkipped.slice(); | ||
// match -> reset | ||
currentTokenPosition = 0; | ||
matchTokens.length = 0; | ||
matchSkipped.length = 0; | ||
return { | ||
match: true, | ||
tokens: tokens | ||
tokens: tokens, | ||
skipped: skipped, | ||
}; | ||
@@ -58,0 +65,0 @@ } |
Sorry, the diff of this file is not supported yet
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
16161
130