Wordle/Japanese_Wordle/packages/scripts/tests/jmdict.ts
2022-03-27 15:16:41 -04:00

26 lines
503 B
TypeScript

import { JMdictXML } from '@/jmdict'
import { ReadLine } from '@/util'
export async function defineXmlSelector() {
const d = new JMdictXML()
const rl = new ReadLine()
while (true) {
const sel = (await rl.question(`selector: `)).trim()
if (!sel) {
break
}
const ent = Array.from(d.$(sel).parents('entry'))
console.log(ent.map((it) => d.$(it).html()).join('\n\n'))
console.log(ent.length)
}
rl.close()
}
if (require.main === module) {
defineXmlSelector()
}