morpheme-match
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -30,10 +30,16 @@ // LICENSE : MIT | ||
return function (token) { | ||
var expectedToken = matchedTokens[currentTokenPosition]; | ||
if (matchToken(token, expectedToken)) { | ||
matchTokens.push(token); | ||
currentTokenPosition += 1; | ||
} else { | ||
// reset position | ||
matchTokens.length = 0; | ||
currentTokenPosition = 0; | ||
while (currentTokenPosition < tokenCount) { | ||
var expectedToken = matchedTokens[currentTokenPosition]; | ||
if (matchToken(token, expectedToken)) { | ||
matchTokens.push(token); | ||
currentTokenPosition += 1; | ||
break; | ||
} else if (expectedToken["_skippable"]) { | ||
currentTokenPosition += 1; | ||
} else { | ||
// reset position | ||
matchTokens.length = 0; | ||
currentTokenPosition = 0; | ||
break; | ||
} | ||
} | ||
@@ -40,0 +46,0 @@ // match all tokens |
@@ -18,3 +18,3 @@ { | ||
], | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"main": "lib/morpheme-match.js", | ||
@@ -21,0 +21,0 @@ "directories": { |
@@ -149,5 +149,30 @@ # morpheme-match [![Build Status](https://travis-ci.org/azu/morpheme-match.svg?branch=master)](https://travis-ci.org/azu/morpheme-match) | ||
]); | ||
`` | ||
``` | ||
キー`_skippable`が`true`の場合はマッチしない場合は無視されます。 | ||
```js | ||
const expectToken = createTokenMatcher([ | ||
{ | ||
"surface_form": "かも", | ||
}, | ||
{ | ||
"surface_form": "、", | ||
"_skippable": true, | ||
}, | ||
{ | ||
"surface_form": "しれ", | ||
}, | ||
]); | ||
``` | ||
## 関連 | ||
- [azu/morpheme-match-all: A wrapper of morpheme-match API. Match all kuromoji's tokens.](https://github.com/azu/morpheme-match-all) | ||
- A wrapper for morpheme-match | ||
- [textlint-ja/textlint-rule-morpheme-match: 形態素解析結果のTokenベースの辞書でマッチするtextlintルール](https://github.com/textlint-ja/textlint-rule-morpheme-match) | ||
## Changelog | ||
@@ -154,0 +179,0 @@ |
@@ -29,10 +29,16 @@ // LICENSE : MIT | ||
return (token) => { | ||
const expectedToken = matchedTokens[currentTokenPosition]; | ||
if (matchToken(token, expectedToken)) { | ||
matchTokens.push(token); | ||
currentTokenPosition += 1; | ||
} else { | ||
// reset position | ||
matchTokens.length = 0; | ||
currentTokenPosition = 0; | ||
while (currentTokenPosition < tokenCount) { | ||
const expectedToken = matchedTokens[currentTokenPosition]; | ||
if (matchToken(token, expectedToken)) { | ||
matchTokens.push(token); | ||
currentTokenPosition += 1; | ||
break; | ||
} else if (expectedToken["_skippable"]) { | ||
currentTokenPosition += 1; | ||
} else { | ||
// reset position | ||
matchTokens.length = 0; | ||
currentTokenPosition = 0; | ||
break; | ||
} | ||
} | ||
@@ -54,2 +60,2 @@ // match all tokens | ||
} | ||
}; | ||
}; |
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
15047
116
206