add example sentences for numbers
This commit is contained in:
1 parent
9dfae88805
commit
1118bda30f
3 files changed
+271
-7
No files matched your search
@@ -41,6 +41,8 @@ export function mp3DownloaderPlugin(): Plugin {
|
||||
END;
|
||||
`);
|
||||
|
||||
let tokenizer: Tokenizer | null = null;
|
||||
|
||||
// Vite dev server middlewares are connect-style: (req, res, next)
|
||||
server.middlewares.use(async (req, res, next) => {
|
||||
const reqUrl = req.url;
|
||||
@@ -50,7 +52,11 @@ export function mp3DownloaderPlugin(): Plugin {
|
||||
if (!url.pathname.endsWith(".mp3")) return next();
|
||||
|
||||
try {
|
||||
await mp3Downloader(db, await Tokenizer.init(), url, res, next);
|
||||
// if (!tokenizer) {
|
||||
// tokenizer = await Tokenizer.init();
|
||||
// }
|
||||
|
||||
await mp3Downloader(db, tokenizer, url, res, next);
|
||||
} catch (e) {
|
||||
console.error(e, reqUrl);
|
||||
next();
|
||||
@@ -71,12 +77,12 @@ async function mp3Downloader(
|
||||
`https://www.howtostudykorean.com/wp-content${url.pathname}`,
|
||||
);
|
||||
|
||||
const text = url.searchParams.get("text");
|
||||
if (text) {
|
||||
db.prepare(
|
||||
"INSERT OR IGNORE INTO sentence ([url], ko, original) VALUES (?, ?, ?)",
|
||||
).run(downloadURL.href, tokenizer.normalize(text), text);
|
||||
}
|
||||
// const text = url.searchParams.get("text");
|
||||
// if (text) {
|
||||
// db.prepare(
|
||||
// "INSERT OR IGNORE INTO sentence ([url], ko, original) VALUES (?, ?, ?)",
|
||||
// ).run(downloadURL.href, tokenizer.normalize(text), text);
|
||||
// }
|
||||
|
||||
const segs = url.pathname.slice(1).split("/");
|
||||
const filename = segs.pop()!;
|
||||
|
||||
Reference in new issue
Block a user