Make a demo?

This commit is contained in:
yuanhau 2025-05-19 14:38:59 +08:00
parent edd8e5b05a
commit 2495911a81
4 changed files with 49 additions and 4 deletions

View file

@ -1,6 +1,17 @@
async function checkUnsafeContent() {
const req = await fetch("/api/contentcheck/kidunfriendlycontent");
const res = await req.json();
import NewsAnalyzer from "~/components/newsAnalyzer";
const newsAnalyzer = new NewsAnalyzer();
async function checkUnsafeContent(title: string) {
try {
const req = await fetch("/api/contentcheck/kidunfriendlycontent");
const res = await req.json();
const patterns = res.words.map((word) => new RegExp(word, "i"));
console.log(patterns);
newsAnalyzer.setSensitivePatterns(patterns);
const kidfriendly = newsAnalyzer.isKidFriendly(title);
return kidfriendly;
} catch (e) {
console.log(e);
}
}
export default checkUnsafeContent;