How might we improve the default filter configuration? #52
Closed
stevepolitodesign
started this conversation in
Ideas
Replies: 2 comments
-
Maybe instead we want this: module TopSecret
include ActiveSupport::Configurable
config_accessor :model_path, default: "ner_model.dat"
config_accessor :min_confidence_score, default: MIN_CONFIDENCE_SCORE
config_accessor :custom_filters do
ActiveSupport::OrderedOptions.new
end
config_accessor :credit_card_filter, default: TopSecret::Filters::Regex.new(label: "CREDIT_CARD", regex: CREDIT_CARD_REGEX)
config_accessor :email_filter, default: TopSecret::Filters::Regex.new(label: "EMAIL", regex: EMAIL_REGEX)
config_accessor :phone_number_filter, default:TopSecret::Filters::Regex.new(label: "PHONE_NUMBER", regex: PHONE_REGEX)
config_accessor :ssn_filter, default:TopSecret::Filters::Regex.new(label: "SSN", regex: SSN_REGEX)
config_accessor :people_filter, default: TopSecret::Filters::NER.new(label: "PERSON", tag: :person)
config_accessor :location_filter, default: TopSecret::Filters::NER.new(label: "LOCATION", tag: :location)
end
new_email_filter = TopSecret::Filters::Regex.new(label: "EMAIL_ADDRESS", regex: /\b\w+\[at\]\w+\.\w+\b/)
# Override a default filter with a keyword argument
TopSecret::Text.filter("Ralph can be reached at ralph[at]thoughtbot.com", email_filter: new_email_filter)
# Add custom filters
language_filter = TopSecret::Filters::NER.new(
label: "LANGUAGE",
tag: :language,
min_confidence_score: 0.75
)
TopSecret::Text.filter("Ralph can be reached at ralph[at]thoughtbot.com", custom_filters: [language_filter]) |
Beta Was this translation helpful? Give feedback.
0 replies
-
This was addressed in #53 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It can be cumbersome and brittle to ensure the filter keys matches an existing default filter. For example:
There are a few problems with this approach:
Beta Was this translation helpful? Give feedback.
All reactions