|
Download task_039/instruction.md from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_039/instruction.md
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_039/instruction.md
-
curl -L -o instruction.md https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_039/instruction.md
1.85 kB
| # Filter and audit sensitive-content submissions | |
| Implement the Go `contentsafety` package in the supplied project. Check questions, answers and comments against a configurable sensitive-word list before accepting them. | |
| ## Interface | |
| ```go | |
| func NewFilter(words []string) *Filter | |
| func LoadWordsFile(path string) ([]string, error) | |
| func NewFilterFromFile(path string) (*Filter, error) | |
| func (f *Filter) SetWords(words []string) | |
| func (f *Filter) Validate(contentType, text string) error | |
| func (f *Filter) Submit(contentType, text string) error | |
| func (f *Filter) AuditLog() []AuditEntry | |
| func (f *Filter) Accepted() []SubmittedEntry | |
| ``` | |
| Keep the `AuditEntry` fields `ContentType`, `Text` and `Word`; expose `ContentType` and `Text` string fields on `SubmittedEntry`. The starter includes UTF-8 `sensitive_words.txt`, one entry per line. An administrator can edit and reload this file or update the API's word list. An administrator UI is optional; no Apache Answer instance is needed. Local packages are allowed; `go test ./...` must work offline. | |
| ## Acceptance Checklist | |
| - Read entries in file order, preserving case, trimming surrounding whitespace and ignoring blank and `#` comment lines. Return an error for a missing or unreadable file. | |
| - For `question`, `answer` and `comment`, detect nonblank configured words as case-insensitive substrings. A match returns an error indicating sensitive content and appends exactly one audit entry with the original text, type and configured word. A clean validation adds no audit entry. | |
| - Clean submissions go to the accepted list; blocked submissions do not. Unsupported types are rejected without changing either list. | |
| - The constructor and `SetWords` take independent snapshots. Updates replace the old list immediately; nil and empty lists clear it. Returned audit and accepted lists are independent snapshots. | |