forked from importcjj/sensitive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/importcjj/sensitive" | ||
) | ||
|
||
func main() { | ||
filter := sensitive.New() | ||
filter.LoadWordDict("../dict/dict.txt") | ||
filter.AddWord("长者") | ||
|
||
fmt.Println(filter.Filter("我为长者续一秒")) // 我为续一秒 | ||
// 42 即 "*" | ||
fmt.Println(filter.Replace("我为长者续一秒", 42)) // 我为**续一秒 | ||
fmt.Println(filter.FindIn("我为长者续一秒")) // true, 长者 | ||
fmt.Println(filter.Validate("我为长者续一秒")) // False, 长者 | ||
fmt.Println(filter.FindAll("我为长者续一秒")) // [长者] | ||
|
||
fmt.Println(filter.FindIn("我为长x者续一秒")) // false | ||
filter.UpdateNoisePattern(`x`) | ||
fmt.Println(filter.FindIn("我为长x者续一秒")) // true, 长者 | ||
fmt.Println(filter.Validate("我为长x者续一秒")) // False, 长者 | ||
} | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/importcjj/sensitive" | ||
) | ||
|
||
func main() { | ||
filter := sensitive.New() | ||
filter.LoadWordDict("../dict/dict.txt") | ||
filter.AddWord("长者") | ||
|
||
fmt.Println(filter.Filter("我为长者续一秒")) // 我为续一秒 | ||
// 42 即 "*" | ||
fmt.Println(filter.Replace("我为长者续一秒", 42)) // 我为**续一秒 | ||
fmt.Println(filter.FindIn("我为长者续一秒")) // true, 长者 | ||
fmt.Println(filter.Validate("我为长者续一秒")) // False, 长者 | ||
fmt.Println(filter.FindAll("我为长者续一秒")) // [长者] | ||
|
||
fmt.Println(filter.FindIn("我为长x者续一秒")) // false | ||
filter.UpdateNoisePattern(`x`) | ||
fmt.Println(filter.FindIn("我为长x者续一秒")) // true, 长者 | ||
fmt.Println(filter.Validate("我为长x者续一秒")) // False, 长者 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/importcjj/sensitive" | ||
) | ||
|
||
func keywordFilterSearch(content string) (bool, string) { | ||
filter := sensitive.New() | ||
filter.AddWord("hello") | ||
// filter.LoadWordDict("./conf/dict.txt") | ||
code, word := filter.FindIn(content) | ||
fmt.Println(content) | ||
fmt.Printf("[%s]\n",word) | ||
fmt.Printf("[%v]\n",code) | ||
return code, word | ||
} | ||
|
||
func main() { | ||
content := `录制 文字 吃猪肉 | ||
sdaddasd | ||
dadasd | ||
dada | ||
教性 | ||
` | ||
keywordFilterSearch(content) | ||
} | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/importcjj/sensitive" | ||
) | ||
|
||
func keywordFilterSearch(content string) (bool, string) { | ||
filter := sensitive.New() | ||
filter.AddWord("hello") | ||
// filter.LoadWordDict("./conf/dict.txt") | ||
code, word := filter.FindIn(content) | ||
fmt.Println(content) | ||
fmt.Printf("[%s]\n", word) | ||
fmt.Printf("[%v]\n", code) | ||
return code, word | ||
} | ||
|
||
func main() { | ||
content := `录制 文字 吃猪肉 | ||
sdaddasd | ||
dadasd | ||
dada | ||
教性 | ||
` | ||
keywordFilterSearch(content) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters