Skip to content

Commit 7d11ca0

Browse files
committed
Initial commit
sanitize special characters support for custom reg matching pattern Create LICENSE.md Update README.md added condition check
0 parents  commit 7d11ca0

File tree

10 files changed

+1776
-0
lines changed

10 files changed

+1776
-0
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build
2+
# this will work for every push
3+
on: ["push"]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
11+
- name: Set up Go
12+
uses: actions/setup-go@v2
13+
with:
14+
go-version: 1.15
15+
16+
- name: Build
17+
run: go build -v ./...
18+
19+
- name: Test
20+
run: go test -v ./...
21+

.github/workflows/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
push:
3+
# Sequence of patterns matched against refs/tags
4+
tags:
5+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6+
7+
name: Create Release
8+
9+
jobs:
10+
build:
11+
name: Create Release
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
- name: Create Release
17+
id: create_release
18+
uses: actions/create-release@v1
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
21+
with:
22+
tag_name: ${{ github.ref }}
23+
release_name: Release ${{ github.ref }}
24+
draft: false
25+
prerelease: false

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
14+
# Dependency directories (remove the comment below to include it)
15+
# vendor/

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 PRATHEESH PC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[![Create Release](https://github.com/pcpratheesh/go-censorword/actions/workflows/release.yml/badge.svg)](https://github.com/pcpratheesh/go-censorword/actions/workflows/release.yml)
2+
3+
# go-censorword
4+
5+
go-censorword is a lightweight library for detecting profanities in Go string.
6+
7+
8+
## Installation
9+
```
10+
go get -u github.com/pcpratheesh/go-censorword
11+
```
12+
## Usage
13+
```go
14+
import (
15+
"github.com/pcpratheesh/go-censorword"
16+
)
17+
```
18+
19+
## In working
20+
go-censorword package uses a censorWord [here](censor/censor.go) list to check the profanities.
21+
Als we have provided an option to override this list of contents by using
22+
```go
23+
CustomCensorList()
24+
```
25+
You can provide your own list to search and replace the profanities
26+
27+
## Example
28+
```go
29+
var detector = gocensorword.NewDetector().SetCensorReplaceChar("*")
30+
detector.CustomCensorList([]string{
31+
"bad", "word","one",
32+
})
33+
```
34+
## Example
35+
```go
36+
detector := NewDetector().SetCensorReplaceChar("*")
37+
38+
resultString, err := detector.CensorWord(inputString)
39+
40+
if err != nil {
41+
panic(err)
42+
}
43+
```
44+
45+
46+
In the future, we should implement the following points
47+
- Support for other language profanities
48+
- All words having repeated characters more than twice (eg : fuck -> fuuuuuck)
49+
- Should remove word match conditions (eg :-> fucker, fucking..etc)

0 commit comments

Comments
 (0)