Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Improve doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
finnbear committed Dec 31, 2020
1 parent 05681b8 commit 7149fcf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion moderation.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"unicode"
)

// Types of inappropriate (combinable with bitwise OR)
type Type uint32

const (
Expand Down Expand Up @@ -57,7 +58,8 @@ var removeAccentsTransform = transform.Chain(norm.NFD, runes.Remove(runes.In(uni
// IsInappropriate returns whether a phrase contains enough inappropriate words
// to meet or exceed InappropriateThreshold
//
// Equivalent to moderation.Is(text, moderation.Profane|moderation.Offensive|moderation.Sexual)
// Equivalent to
// moderation.Is(text, moderation.Profane|moderation.Offensive|moderation.Sexual)
//
func IsInappropriate(text string) bool {
return Is(text, Profane|Offensive|Sexual)
Expand Down
11 changes: 6 additions & 5 deletions moderation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package moderation

import (
"encoding/csv"
"fmt"
"io"
"os"
"testing"
Expand Down Expand Up @@ -69,23 +70,23 @@ func TestAnalyze(t *testing.T) {
}
}

func IsExamples_shit_profane() {
func ExampleIs_shit_profane() {
fmt.Println(Is("shit", Profane))
// Output: true
}

func IsExamples_shit_sexual_or_mean() {
func ExampleIs_shit_sexual_or_mean() {
fmt.Println(Is("shit", Sexual|Mean))
// Output: false
}

func IsInappropriateExamples_hello() {
func ExampleIsInappropriate_hello() {
fmt.Println(IsInappropriate("hello"))
// Output: false
}

func IsInappropriateExamples_shit() {
fmt.Println(IsInappropriate("shit"))
func ExampleIsInappropriate_sh1t() {
fmt.Println(IsInappropriate("sh1t"))
// Output: true
}

Expand Down

0 comments on commit 7149fcf

Please sign in to comment.