-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
596 additions
and
1,397 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const kuromoji = require('kuromoji') | ||
|
||
module.exports = debug => { | ||
return new Promise((resolve, reject) => { | ||
if (debug) console.time('#### ビルド時間') | ||
kuromoji.builder({ | ||
dicPath: __dirname + '/../node_modules/kuromoji/dict' | ||
}).build(function(err, _tokenizer) { | ||
if (err) { | ||
console.error('エラー: kuromojiのビルド失敗') | ||
reject(err) | ||
} | ||
if (debug) {console.timeEnd('#### ビルド時間'); console.log()} | ||
resolve(_tokenizer) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
module.exports = { | ||
文字参照を文字に: str => { | ||
return str.replace(/&#x[0-9a-fA-F]+;/gm, e => String.fromCharCode(e.replace(/&#/, '0').replace(/;/, ''))) | ||
}, | ||
ひらがなへ: 文字列 => { | ||
return 文字列.replace(/[ァ-ヴ]/g, (カタカナ) => { | ||
return String.fromCharCode(カタカナ.charCodeAt(0) - 96) | ||
}) | ||
}, | ||
カタカナへ: 文字列 => { | ||
return 文字列.replace(/[ぁ-ゔ]/g, (ひらがな) => { | ||
return String.fromCharCode(ひらがな.charCodeAt(0) + 96); | ||
}); | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.