1
0
Fork 0
mirror of https://github.com/kou029w/daraz-san.git synced 2025-01-18 16:08:06 +00:00
daraz-san/scripts/morpheme.js
2020-04-09 00:24:48 +09:00

26 lines
720 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { directMention } = require("@slack/bolt");
const { useTokenize, toCSV } = require("./util/morpheme");
const nyanco = require("./util/nyanco");
// Description:
// すもももももももものうち
//
// Synopsis:
// morpheme <phrase> - <phrase> を形態素解析器にかけるにゃーん
module.exports = [
directMention(),
/morpheme (.*)/i,
async ({ context, say }) => {
try {
const tokenize = await useTokenize();
const tokens = tokenize(context.matches[1]);
const readings = tokens.map(({ reading }) => reading);
return say(
[`${nyanco()} ${readings.join("")}`, toCSV(tokens)].join("\n")
);
} catch (e) {
console.error(e);
}
},
];