A wrapper of morpheme-match API. Match all kuromoji's tokens.
npm install morpheme-match-allA wrapper of morpheme-match API. Match all kuromoji's tokens.
kuromojinのtoken同士を比較して、
形態素解析結果を元にしたtoken辞書による比較を行うライブラリです。
Install with npm:
npm install morpheme-match-all
morpheme-match-all compare two kuromoji's tokens using morpheme-match.
You can see kuromoji's tokens at azu.github.io/morpheme-match/.
Define dictionary as tokens list.
``js"することができる"は有害 http://qiita.com/takahi-i/items/a93dc2ff42af6b93f6e0
"use strict";
module.exports = [
{
// https://azu.github.io/morpheme-match/?text=解析(することができます)。
message: ,`
tokens: [
{
"surface_form": "する",
"pos": "動詞",
"pos_detail_1": "自立",
"pos_detail_2": "*",
"pos_detail_3": "*",
"conjugated_type": "サ変・スル",
"conjugated_form": "基本形",
"basic_form": "する",
"reading": "スル",
"pronunciation": "スル"
},
{
"surface_form": "こと",
"pos": "名詞",
"pos_detail_1": "非自立",
"pos_detail_2": "一般",
"pos_detail_3": "*",
"conjugated_type": "*",
"conjugated_form": "*",
"basic_form": "こと",
"reading": "コト",
"pronunciation": "コト"
},
{
"surface_form": "が",
"pos": "助詞",
"pos_detail_1": "格助詞",
"pos_detail_2": "一般",
"pos_detail_3": "*",
"conjugated_type": "*",
"conjugated_form": "*",
"basic_form": "が",
"reading": "ガ",
"pronunciation": "ガ"
},
{
"pos": "動詞",
"pos_detail_1": "自立",
"conjugated_type": "一段",
"conjugated_form": "連用形",
"basic_form": "できる",
}
]
}
];
morpheme-match-all the actual tokens generated by kuromojin(kuromoji.js).
`js`
const kuromojin = require("kuromojin");
const {createMatcher} = require("morpheme-match-all");
const dictionaries = require("./fixtures/dictionary");
const matchAll = createMatcher(dictionaries);
return kuromojin("解析することができます。").then((actualTokens) => {
const results = matchAll(actualTokens);
/**
[ { tokens: [ [Object], [Object], [Object], [Object] ],
index: 1,
expected:
{ message: '"することができる"は有害 http://qiita.com/takahi-i/items/a93dc2ff42af6b93f6e0',
tokens: [Object] } } ]
*/
});
#### Table of Contents
- [ExpectedDictionary][1]
- [Properties][2]
- [MatchResult][3]
- [Properties][4]
- [createMatcher][5]
- [Parameters][6]
- [morphemeMatchAll][7]
- [Parameters][8]
Type: [Object][9]
#### Properties
- tokens [Array][10]<[Object][9]> kuromoji's token listmessage
- [string][11]? expected
- [string][11]?
Type: [Object][9]
#### Properties
- tokens [Array][10]<[Object][9]> match tokens,index
- [number][12] index of first match tokenskipped
- [Array][10]<[boolean][13]> skipped values for tokensdict
- [Array][10]<[ExpectedDictionary][14]> dictionary defined by you
#### Parameters
- dictionaries [Array][10]<[ExpectedDictionary][14]>
Returns [morphemeMatchAll][15]
match actualTokens with dictionaries
#### Parameters
- actualTokens [Array][10]<[Object][9]>
Returns [Array][10]<[MatchResult][16]>
[1]: #expecteddictionary
[2]: #properties
[3]: #matchresult
[4]: #properties-1
[5]: #creatematcher
[6]: #parameters
[7]: #morphemematchall
[8]: #parameters-1
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[14]: #expecteddictionary
[15]: #morphemematchall
[16]: #matchresult
- textlint-ja/textlint-rule-no-insert-dropping-sa: サ抜き、サ入れ表現の誤用をチェックするtextlintルール
- textlint-ja/textlint-rule-ja-no-redundant-expression: 冗長な表現を禁止するtextlintルール
See Releases page.
Install devDependencies and Run npm test:
npm i -d && npm test
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
1. Fork it!
2. Create your feature branch: git checkout -b my-new-featuregit commit -am 'Add some feature'
3. Commit your changes: git push origin my-new-feature`
4. Push to the branch:
5. Submit a pull request :D
MIT © azu