Skip to content

Commit

Permalink
feat: ignore _ prefix key
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Dec 3, 2016
1 parent 688a2c6 commit 0c40c8f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 4 additions & 0 deletions src/morpheme-match.js
Original file line number Diff line number Diff line change
Expand Up @@ -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": ["名詞", "副詞"]
Expand Down

0 comments on commit 0c40c8f

Please sign in to comment.