mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 21:14:23 +00:00
Switch to a different algroithm.
This commit is contained in:
parent
25927ad13c
commit
f8879b307c
9 changed files with 72 additions and 16 deletions
|
@ -106,4 +106,8 @@ Apperently, there is something called a "hybrid listing" which is s simple recom
|
||||||
```
|
```
|
||||||
This is 100% easier to work with, and with a another extra, I can easily search shitty news terms. Also there is as category type??? What?
|
This is 100% easier to work with, and with a another extra, I can easily search shitty news terms. Also there is as category type??? What?
|
||||||
|
|
||||||
Also the id can just work with the following pattern in regex: `news_cat:[a-zA-Z0-9]{24}`
|
Also the id can just work with the following pattern in regex: `news_cat:[a-zA-Z0-9]{24}`, there is also `top_foryou:[a-zA-Z0-9]{24}`
|
||||||
|
|
||||||
|
### Hybrid listings?
|
||||||
|
- news_cat
|
||||||
|
- top_foryou
|
||||||
|
|
3
bun.lock
3
bun.lock
|
@ -17,6 +17,7 @@
|
||||||
"@tailwindcss/vite": "^4.1.5",
|
"@tailwindcss/vite": "^4.1.5",
|
||||||
"@uploadthing/nuxt": "^7.1.7",
|
"@uploadthing/nuxt": "^7.1.7",
|
||||||
"@vueuse/core": "^13.1.0",
|
"@vueuse/core": "^13.1.0",
|
||||||
|
"ahocorasick": "^1.0.2",
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
"argon2": "^0.43.0",
|
"argon2": "^0.43.0",
|
||||||
"axios": "^1.9.0",
|
"axios": "^1.9.0",
|
||||||
|
@ -884,6 +885,8 @@
|
||||||
|
|
||||||
"agentkeepalive": ["agentkeepalive@4.6.0", "", { "dependencies": { "humanize-ms": "^1.2.1" } }, "sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ=="],
|
"agentkeepalive": ["agentkeepalive@4.6.0", "", { "dependencies": { "humanize-ms": "^1.2.1" } }, "sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ=="],
|
||||||
|
|
||||||
|
"ahocorasick": ["ahocorasick@1.0.2", "", {}, "sha512-hCOfMzbFx5IDutmWLAt6MZwOUjIfSM9G9FyVxytmE4Rs/5YDPWQrD/+IR1w+FweD9H2oOZEnv36TmkjhNURBVA=="],
|
||||||
|
|
||||||
"ajv": ["ajv@6.12.6", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g=="],
|
"ajv": ["ajv@6.12.6", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g=="],
|
||||||
|
|
||||||
"algoliasearch": ["algoliasearch@5.25.0", "", { "dependencies": { "@algolia/client-abtesting": "5.25.0", "@algolia/client-analytics": "5.25.0", "@algolia/client-common": "5.25.0", "@algolia/client-insights": "5.25.0", "@algolia/client-personalization": "5.25.0", "@algolia/client-query-suggestions": "5.25.0", "@algolia/client-search": "5.25.0", "@algolia/ingestion": "1.25.0", "@algolia/monitoring": "1.25.0", "@algolia/recommend": "5.25.0", "@algolia/requester-browser-xhr": "5.25.0", "@algolia/requester-fetch": "5.25.0", "@algolia/requester-node-http": "5.25.0" } }, "sha512-n73BVorL4HIwKlfJKb4SEzAYkR3Buwfwbh+MYxg2mloFph2fFGV58E90QTzdbfzWrLn4HE5Czx/WTjI8fcHaMg=="],
|
"algoliasearch": ["algoliasearch@5.25.0", "", { "dependencies": { "@algolia/client-abtesting": "5.25.0", "@algolia/client-analytics": "5.25.0", "@algolia/client-common": "5.25.0", "@algolia/client-insights": "5.25.0", "@algolia/client-personalization": "5.25.0", "@algolia/client-query-suggestions": "5.25.0", "@algolia/client-search": "5.25.0", "@algolia/ingestion": "1.25.0", "@algolia/monitoring": "1.25.0", "@algolia/recommend": "5.25.0", "@algolia/requester-browser-xhr": "5.25.0", "@algolia/requester-fetch": "5.25.0", "@algolia/requester-node-http": "5.25.0" } }, "sha512-n73BVorL4HIwKlfJKb4SEzAYkR3Buwfwbh+MYxg2mloFph2fFGV58E90QTzdbfzWrLn4HE5Czx/WTjI8fcHaMg=="],
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
import NewsAnalyzer from "~/components/newsAnalyzer";
|
// Trying out the ahocorasick algorithm
|
||||||
const newsAnalyzer = new NewsAnalyzer();
|
// Recommended by: https://www.threads.com/@hsinspeng/post/DJ3yVGQxBg7
|
||||||
|
import AhoCorasick from "ahocorasick";
|
||||||
|
|
||||||
async function checkUnsafeContent(title: string) {
|
async function checkUnsafeContent(title: string) {
|
||||||
try {
|
try {
|
||||||
const req = await fetch("/api/contentcheck/kidunfriendlycontent");
|
const req = await fetch("/api/contentcheck/kidunfriendlycontent");
|
||||||
const res = await req.json();
|
const res = await req.json();
|
||||||
const patterns = res.words.map((word) => new RegExp(word, "i"));
|
console.log(res.words);
|
||||||
console.log(patterns);
|
const ac = new AhoCorasick(res.words);
|
||||||
newsAnalyzer.setSensitivePatterns(patterns);
|
const kidfriendly = ac.search(title);
|
||||||
const kidfriendly = newsAnalyzer.isKidFriendly(title);
|
console.log(kidfriendly);
|
||||||
return !kidfriendly;
|
return kidfriendly;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
"大露",
|
"大露",
|
||||||
"色誘",
|
"色誘",
|
||||||
"死亡",
|
"死亡",
|
||||||
"撩妹"
|
"撩妹",
|
||||||
|
"裸上身"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"@tailwindcss/vite": "^4.1.5",
|
"@tailwindcss/vite": "^4.1.5",
|
||||||
"@uploadthing/nuxt": "^7.1.7",
|
"@uploadthing/nuxt": "^7.1.7",
|
||||||
"@vueuse/core": "^13.1.0",
|
"@vueuse/core": "^13.1.0",
|
||||||
|
"ahocorasick": "^1.0.2",
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
"argon2": "^0.43.0",
|
"argon2": "^0.43.0",
|
||||||
"axios": "^1.9.0",
|
"axios": "^1.9.0",
|
||||||
|
|
24
pages/test.vue
Normal file
24
pages/test.vue
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import CheckKidUnfriendlyContent from "~/components/checks/checkKidUnfriendlyContent";
|
||||||
|
const title = ref("");
|
||||||
|
const system = ref("");
|
||||||
|
const checkTitle = async () => {
|
||||||
|
if (!title.value) return;
|
||||||
|
system.value = await CheckKidUnfriendlyContent(title.value);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="flex flex-col absolute h-screen w-full inset-0 justify-center align-center text-center"
|
||||||
|
>
|
||||||
|
<h1 class="text-4xl m-2">標體?</h1>
|
||||||
|
<div class="flex flex-row justify-center align-center gap-2">
|
||||||
|
<input type="text" class="text-black rounded-xl p-2 w-[300px]" />
|
||||||
|
<button @click="checkTitle" class="rounded-xl bg-sky-600 p-2">
|
||||||
|
Find
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div>{{ system }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="h-screen"></div>
|
||||||
|
</template>
|
|
@ -2,9 +2,10 @@
|
||||||
import CheckKidUnfriendlyContent from "~/components/checks/checkKidUnfriendlyContent";
|
import CheckKidUnfriendlyContent from "~/components/checks/checkKidUnfriendlyContent";
|
||||||
const title = ref("");
|
const title = ref("");
|
||||||
const system = ref(false);
|
const system = ref(false);
|
||||||
|
const testingReturn = ref("");
|
||||||
const checkTitle = async () => {
|
const checkTitle = async () => {
|
||||||
if (!title.value) return;
|
if (!title.value) return;
|
||||||
system.value = await CheckKidUnfriendlyContent(title.value);
|
testingReturn.value = await CheckKidUnfriendlyContent(title.value);
|
||||||
};
|
};
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
title: "這個文章是不是使用偏色情的標體?",
|
title: "這個文章是不是使用偏色情的標體?",
|
||||||
|
@ -16,11 +17,7 @@ useSeoMeta({
|
||||||
>
|
>
|
||||||
<h1 class="text-4xl m-2">這個文章是不是使用偏色情的標體?</h1>
|
<h1 class="text-4xl m-2">這個文章是不是使用偏色情的標體?</h1>
|
||||||
<div class="flex flex-row justify-center align-center gap-2">
|
<div class="flex flex-row justify-center align-center gap-2">
|
||||||
<input
|
<input type="text" class="text-black rounded-xl p-2 w-[300px]" />
|
||||||
type="text"
|
|
||||||
v-model="title"
|
|
||||||
class="text-black rounded-xl p-2 w-[300px]"
|
|
||||||
/>
|
|
||||||
<button @click="checkTitle" class="rounded-xl bg-sky-600 p-2">
|
<button @click="checkTitle" class="rounded-xl bg-sky-600 p-2">
|
||||||
Find
|
Find
|
||||||
</button>
|
</button>
|
||||||
|
@ -28,5 +25,6 @@ useSeoMeta({
|
||||||
<span v-if="system" class="text-red-400 text-8xl m-8">是</span>
|
<span v-if="system" class="text-red-400 text-8xl m-8">是</span>
|
||||||
<span v-else class="text-white">不是</span>
|
<span v-else class="text-white">不是</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div>{{ testingReturn }}</div>
|
||||||
<div class="h-screen"></div>
|
<div class="h-screen"></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -17,6 +17,13 @@ export default defineEventHandler(async (event) => {
|
||||||
"裸照",
|
"裸照",
|
||||||
"性感",
|
"性感",
|
||||||
"找妹",
|
"找妹",
|
||||||
|
"肉蹼",
|
||||||
|
"超兇北半球",
|
||||||
|
"大露",
|
||||||
|
"色誘",
|
||||||
|
"死亡",
|
||||||
|
"撩妹",
|
||||||
|
"裸上身",
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -73,7 +73,23 @@ export default defineEventHandler(async (event) => {
|
||||||
if (noDup.includes(key)) {
|
if (noDup.includes(key)) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
noDup.push(key);
|
noDup.push({
|
||||||
|
type: "nuuid",
|
||||||
|
content: key,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const nonUUIDbutValidLinks = data.filter((id) =>
|
||||||
|
/.*:[a-zA-Z0-9]{24}/g.test(id),
|
||||||
|
);
|
||||||
|
nonUUIDbutValidLinks.forEach((key) => {
|
||||||
|
if (noDup.includes(key)) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
noDup.push({
|
||||||
|
type: "vUUID",
|
||||||
|
content: key,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue