Class: Locallingo::Quality::Terminology
- Inherits:
-
Object
- Object
- Locallingo::Quality::Terminology
- Defined in:
- lib/locallingo/quality/terminology.rb
Overview
Business/domain terminology checks. A term maps to a suggestion string, or
to nil when the term is acceptable (present only so it is documented as
reviewed). Selected by quality.terminology: a built-in name ("business",
"banking", "none") or a path to a custom YAML file.
Constant Summary collapse
- BUSINESS =
Generic business terminology (the cosmos-2 default).
{ "wire transfer" => "Consider 'bank transfer' for broader understanding", "checking account" => "Use 'current account' for non-US markets", "savings account" => nil, "routing number" => "Use 'sort code' (UK) or 'branch code' for non-US", "zip code" => "Use 'postal code' for international audiences", "transaction" => nil, "company" => nil, "business" => nil, "customer" => nil, "client" => nil, "beneficiary" => nil, "payee" => nil, "kyc" => nil, "kyb" => nil }.freeze
- BANKING =
Banking terminology (the zazu/app default) — a superset of BUSINESS with extra always-acceptable regulatory terms.
BUSINESS.merge( "know your customer" => nil, "know your business" => nil, "aml" => nil, "cdd" => nil ).freeze
- BUILTINS =
{ "business" => BUSINESS, "banking" => BANKING, "none" => {} }.freeze
Instance Attribute Summary collapse
-
#terms ⇒ Object
readonly
Returns the value of attribute terms.
Instance Method Summary collapse
-
#check(key, text, locale) ⇒ Object
Suggestions for flagged (non-nil) terms found in
text. -
#initialize(setting, base_path: Dir.pwd) ⇒ Terminology
constructor
settingis a built-in name, a path to a YAML file, or nil (=> business).
Constructor Details
#initialize(setting, base_path: Dir.pwd) ⇒ Terminology
setting is a built-in name, a path to a YAML file, or nil (=> business).
44 45 46 |
# File 'lib/locallingo/quality/terminology.rb', line 44 def initialize(setting, base_path: Dir.pwd) @terms = resolve(setting, base_path) end |
Instance Attribute Details
#terms ⇒ Object (readonly)
Returns the value of attribute terms.
41 42 43 |
# File 'lib/locallingo/quality/terminology.rb', line 41 def terms @terms end |
Instance Method Details
#check(key, text, locale) ⇒ Object
Suggestions for flagged (non-nil) terms found in text.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/locallingo/quality/terminology.rb', line 49 def check(key, text, locale) terms.filter_map do |term, suggestion| next unless suggestion next unless text.downcase.include?(term.downcase) { key:, text:, locale:, category: :terminology, issue: suggestion, match: term, severity: :info, source: :static } end end |