Allow different dictionaries #17

Merged
sp-adrian-perez merged 4 commits from allow_different_dictionaries into master 2021-08-02 22:29:02 -04:00
sp-adrian-perez commented 2021-07-21 03:07:18 -04:00 (Migrated from github.com)

This PR is related with the issue #16.

So I created a new functional function to enable a way where you can load different profanities, falseNegatives and falsePositives in this way this library will be more versatile, also I modified the test related and the README

This PR is related with the issue #16. So I created a new functional function to enable a way where you can load different `profanities`, `falseNegatives` and `falsePositives` in this way this library will be more versatile, also I modified the test related and the README
TwiN (Migrated from github.com) requested changes 2021-07-22 18:08:11 -04:00
TwiN (Migrated from github.com) left a comment

Nicely done @sp-adrian-perez, and thank you for your contribution!

Could you export the default dictionary arrays (i.e. defaultProfanities -> DefaultProfanities, etc.)?

My reasoning behind that is, what if somebody just wants to add a single word to the default dictionary? By making these variables, they'll be able to (e.g. WithCustomDictionary(append(goaway.DefaultProfanities, "badword"), ...)).

Nicely done @sp-adrian-perez, and thank you for your contribution! Could you export the default dictionary arrays (i.e. `defaultProfanities` -> `DefaultProfanities`, etc.)? My reasoning behind that is, what if somebody just wants to add a single word to the default dictionary? By making these variables, they'll be able to (e.g. `WithCustomDictionary(append(goaway.DefaultProfanities, "badword"), ...)`).
sp-adrian-perez commented 2021-07-28 07:44:20 -04:00 (Migrated from github.com)

Yes of course, sorry for the delay on answer you I'm a little bit busy these days, so the idea is maintain also the WithCustomDictionary function and add export the defaults right?

Yes of course, sorry for the delay on answer you I'm a little bit busy these days, so the idea is maintain also the `WithCustomDictionary` function and add export the defaults right?
TwiN commented 2021-07-30 02:10:36 -04:00 (Migrated from github.com)

Yes of course, sorry for the delay on answer you I'm a little bit busy these days, so the idea is maintain also the WithCustomDictionary function and add export the defaults right?

No problem :)

And yes, all you have to do is change the first character of the default dictionaries (e.g. defaultProfanities) from lowercase to uppercase (DefaultProfanities).

> Yes of course, sorry for the delay on answer you I'm a little bit busy these days, so the idea is maintain also the `WithCustomDictionary` function and add export the defaults right? No problem :) And yes, all you have to do is change the first character of the default dictionaries (e.g. `defaultProfanities`) from lowercase to uppercase (`DefaultProfanities`).
sp-adrian-perez commented 2021-07-30 06:15:40 -04:00 (Migrated from github.com)

Perfect!! done :)

Perfect!! done :)
TwiN (Migrated from github.com) requested changes 2021-07-30 12:54:00 -04:00
TwiN (Migrated from github.com) left a comment

Just a few little changes and I think we're good to go

Just a few little changes and I think we're good to go
@ -1,14 +1,14 @@
package goaway
TwiN (Migrated from github.com) commented 2021-07-30 12:53:27 -04:00
// DefaultFalseNegatives is a list of profanities that are checked for before the DefaultFalsePositives are removed
```suggestion // DefaultFalseNegatives is a list of profanities that are checked for before the DefaultFalsePositives are removed ```
@ -61,0 +74,4 @@
g.falseNegatives = falseNegatives
g.falsePositives = falsePositives
return g
TwiN (Migrated from github.com) commented 2021-07-30 12:53:00 -04:00
// IsProfane takes in a string (word or sentence) and look for profanities.
```suggestion // IsProfane takes in a string (word or sentence) and look for profanities. ```
@ -70,3 +89,3 @@
}
// Remove false positives
for _, word := range falsePositives {
for _, word := range g.falsePositives {
TwiN (Migrated from github.com) commented 2021-07-30 12:52:53 -04:00
	// Check for profanities
```suggestion // Check for profanities ```
@ -1,9 +1,9 @@
package goaway
TwiN (Migrated from github.com) commented 2021-07-30 12:52:21 -04:00
// DefaultProfanities is a list of profanities that are checked after the DefaultFalsePositives are removed
```suggestion // DefaultProfanities is a list of profanities that are checked after the DefaultFalsePositives are removed ```
TwiN (Migrated from github.com) approved these changes 2021-08-02 22:26:51 -04:00
codecov-commenter commented 2021-08-02 22:27:23 -04:00 (Migrated from github.com)

Codecov Report

Merging #17 (945a294) into master (9b55b8d) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #17   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           65        73    +8     
=========================================
+ Hits            65        73    +8     
Impacted Files Coverage Δ
goaway.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b55b8d...945a294. Read the comment docs.

# [Codecov](https://codecov.io/gh/TwinProduction/go-away/pull/17?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.) Report > Merging [#17](https://codecov.io/gh/TwinProduction/go-away/pull/17?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.) (945a294) into [master](https://codecov.io/gh/TwinProduction/go-away/commit/9b55b8d3242debd4e6d3967f79e46cd9de0af7f0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.) (9b55b8d) will **not change** coverage. > The diff coverage is `100.00%`. [![Impacted file tree graph](https://codecov.io/gh/TwinProduction/go-away/pull/17/graphs/tree.svg?width=650&height=150&src=pr&token=25T9OQT9TM&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.)](https://codecov.io/gh/TwinProduction/go-away/pull/17?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.) ```diff @@ Coverage Diff @@ ## master #17 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 1 1 Lines 65 73 +8 ========================================= + Hits 65 73 +8 ``` | [Impacted Files](https://codecov.io/gh/TwinProduction/go-away/pull/17?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.) | Coverage Δ | | |---|---|---| | [goaway.go](https://codecov.io/gh/TwinProduction/go-away/pull/17/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.#diff-Z29hd2F5Lmdv) | `100.00% <100.00%> (ø)` | | ------ [Continue to review full report at Codecov](https://codecov.io/gh/TwinProduction/go-away/pull/17?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.) > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://codecov.io/gh/TwinProduction/go-away/pull/17?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.). Last update [9b55b8d...945a294](https://codecov.io/gh/TwinProduction/go-away/pull/17?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Chris+C.).
TwiN commented 2021-08-02 22:29:05 -04:00 (Migrated from github.com)

@sp-adrian-perez Thank you for your contribution!

@sp-adrian-perez Thank you for your contribution!
TwiN commented 2021-08-02 23:01:22 -04:00 (Migrated from github.com)

Released in v1.2.0

By the way, I swapped the order for the false positive and false negative order, so the order is now the following:

profanityDetector := goaway.NewProfanityDetector().WithCustomDictionary(profanities, falsePositives, falseNegatives)
Released in [v1.2.0](https://github.com/TwinProduction/go-away/releases/tag/v1.2.0) By the way, I swapped the order for the false positive and false negative order, so the order is now the following: ```go profanityDetector := goaway.NewProfanityDetector().WithCustomDictionary(profanities, falsePositives, falseNegatives) ```
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
TwiN/go-away!17
No description provided.