Comments (4)
Have you tried using WithSanitizeSpaces(false)
?
from go-away.
Hi @TwiN
Yes I tried using WithSanitizeSapces(false) -> it removes the spaces in the the string. But still it is not working.
I tried modifying the code but not able. The thing is instead of doing substring search, I need to search for exact word.
from go-away.
Ah you're right, yeah. We'd need to add a new WithExactWord(bool)
feature
from go-away.
I got this with the below code
for currentIndex != -1 {
if currentIndex == 0 {
searchWord = word + " "
wordPlacement = 1
}
if len([]rune(" "+word))+strings.LastIndex(s, " "+word) == len([]rune(s)) {
searchWord = " " + word
wordPlacement = 2
}
str := strings.Split(s, " ")
if len(str) == 1 {
if foundIndex := strings.Index(s[currentIndex:], strings.TrimSpace(searchWord)); foundIndex != -1 {
for i := 0; i < len([]rune(strings.TrimSpace(searchWord))); i++ {
runeIndex := g.indexToRune(string(censored), currentIndex+foundIndex+i)
censored[originalIndexes[runeIndex]] = '*'
}
currentIndex += foundIndex + len([]rune(strings.TrimSpace(searchWord)))
} else {
break
}
}
if foundIndex := strings.Index(s[currentIndex:], searchWord); foundIndex != -1 {
if wordPlacement == 0 {
for i := 0; i < len([]rune(searchWord))-1; i++ {
runeIndex := g.indexToRune(string(censored), currentIndex+foundIndex+i)
censored[originalIndexes[runeIndex]] = '*'
}
currentIndex += foundIndex + len([]rune(searchWord))
}
if wordPlacement == 1 {
for i := 0; i < len([]rune(strings.TrimSpace(searchWord))); i++ {
runeIndex := g.indexToRune(string(censored), currentIndex+foundIndex+i)
censored[originalIndexes[runeIndex]] = '*'
}
currentIndex += foundIndex + len([]rune(strings.TrimSpace(searchWord)))
}
if wordPlacement == 2 {
for i := 1; i < len([]rune(strings.TrimSpace(searchWord)))+1; i++ {
runeIndex := g.indexToRune(string(censored), currentIndex+foundIndex+i)
censored[originalIndexes[runeIndex]] = '*'
}
currentIndex += foundIndex + len([]rune(strings.TrimSpace(searchWord)))
}
wordPlacement = 0
} else {
break
}
}
from go-away.
Related Issues (20)
- "Scunthorpe" is detected as profane HOT 1
- Allow using different profanities HOT 1
- Strange cases of profanity HOT 2
- Index out of range error when censoring cyrillic language HOT 2
- go test -race is issuing WARNING: DATA RACE in IsProfane() HOT 3
- False positives: "can use", "via ssh" HOT 7
- Duplicate false positive causes panic HOT 5
- Duplicate false negatives and profanities break censoring
- False Positives: Kassie, Kassidy, Kassandra HOT 2
- Add butterfly to false positives HOT 2
- bug: Custom Dictionaries Uppercased fails to match HOT 1
- bug: runtime error: index out of range [-1] when using custom profanity list
- bug: incorrect position replaced
- bug: panic, when using utf-8 HOT 2
- Support for multiple languages HOT 4
- False positive: "therapeutic"
- False positive: "button"
- Fix (False Positive): Tassilo
- Extract a list of bad words not just the first one
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-away.