diff --git a/README.md b/README.md index d2db743..4efd6ce 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,29 @@ console.log(resultTokens); */ ``` +### Tips + +morpheme-matchは`_`から始まるキーを無視するため、メタ情報は`_`で書き込む事ができます。 + +```js +const expectToken = createTokenMatcher([ + { + "surface_form": "かも", + "pos": "助詞", + "pos_detail_1": "副助詞", + "pos_detail_2": "*", + "pos_detail_3": "*", + "conjugated_type": "*", + "conjugated_form": "*", + "basic_form": "かも", + "reading": "カモ", + "pronunciation": "カモ", + "_cature": "$1" + } +]); +`` + + ## Changelog See [Releases page](https://github.com/azu/morpheme-match/releases). diff --git a/src/morpheme-match.js b/src/morpheme-match.js index 036daaf..4a59e7c 100644 --- a/src/morpheme-match.js +++ b/src/morpheme-match.js @@ -2,6 +2,10 @@ "use strict"; function matchToken(token, expectShape) { return Object.keys(expectShape).every(key => { + // Ignore start with _ key + if (key[0] === "_") { + return true; + } const actualValue = token[key]; // support multiple value // "pos": ["名詞", "副詞"]