migrate to root dir
This commit is contained in:
20
lib/pipeline/sanitizer.ts
Normal file
20
lib/pipeline/sanitizer.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
const FORBIDDEN_WORDS = ["darn", "heck", "gosh"];
|
||||
|
||||
export function sanitizeText(storyName: string): string {
|
||||
const sourcePath = path.join("stories", storyName, "source.txt");
|
||||
if (!fs.existsSync(sourcePath)) {
|
||||
throw new Error(`Source text not found for story: ${storyName}`);
|
||||
}
|
||||
|
||||
let text = fs.readFileSync(sourcePath, "utf8");
|
||||
|
||||
FORBIDDEN_WORDS.forEach((word) => {
|
||||
const regex = new RegExp(`\\b${word}\\b`, "gi");
|
||||
text = text.replace(regex, "***");
|
||||
});
|
||||
|
||||
return text;
|
||||
}
|
Reference in New Issue
Block a user