Skip to content

Collapse repeated characters (possibly using regex) #8

@finnbear

Description

@finnbear

The program

package main

import (
	"fmt"
	"github.com/TwinProduction/go-away"
)

func main() {
	test("shit")
	test("shiit")
	test("shiiiiiit")
}

func test(word string) {
	fmt.Printf("\"%s\" profane? %t\n", word, goaway.IsProfane(word))
}

prints

"shit" profane? true
"shiit" profane? false
"shiiiiiit" profane? false

I suggest you include a list of regexes to match cases such as this.

An alternative would be to collapse all repeated characters before matching, although this would have an issue with any profanities that contain repeated characters that are no longer profane once collapsed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions