Module: TWFilter
- Defined in:
- lib/twfilter.rb,
lib/twfilter/han.rb,
lib/twfilter/block.rb,
lib/twfilter/errors.rb,
lib/twfilter/policy.rb,
lib/twfilter/tables.rb,
lib/twfilter/finding.rb,
lib/twfilter/subject.rb,
lib/twfilter/version.rb,
lib/twfilter/evidence.rb,
lib/twfilter/sentences.rb,
lib/twfilter/punctuation.rb,
lib/twfilter/checks/erhua.rb,
lib/twfilter/checks/shape.rb,
lib/twfilter/checks/script.rb,
lib/twfilter/checks/wenyan.rb,
lib/twfilter/checks/lexicon.rb,
sig/twfilter.rbs
Defined Under Namespace
Modules: Block, Checks, Evidence, Han, Punctuation, Sentences, Tables, _Check
Classes: Error, Finding, InvalidTableError, MissingTableError, Policy, Report, Subject
Constant Summary
collapse
- CHECKS =
[Checks::Shape, Checks::Script, Checks::Lexicon, Checks::Erhua, Checks::Wenyan].freeze
- TIERS =
教育部 chart indices, ordered by decreasing frequency of use.
{common: 0, secondary: 1, rare: 2}.freeze
- DETAIL_SAMPLE =
Offending items quoted in a finding detail. The check fires on all of them; this only
bounds log width.
4
- VERSION =
"1.0.0"
Class Method Summary
collapse
Class Method Details
.examine(text, policy: Policy.corpus, checks: CHECKS) ⇒ Report
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/twfilter.rb', line 26
def examine(text, policy: Policy.corpus, checks: CHECKS)
subject = Subject.new(text, policy: policy)
findings = checks.flat_map { |check| check.call(subject) }
Report.new(
text: subject.text,
findings: findings.freeze,
tier: Checks::Script.tier_of(subject.text),
han: subject.han,
evidence: Evidence.count(subject.text)
)
end
|
.keep?(text, policy: Policy.corpus) ⇒ Boolean
39
|
# File 'lib/twfilter.rb', line 39
def keep?(text, policy: Policy.corpus) = examine(text, policy: policy).ok?
|
.normalize(text, **options) ⇒ ::String
41
|
# File 'lib/twfilter.rb', line 41
def normalize(text, **options) = Punctuation.normalize(text, **options)
|
.provenance ⇒ ::Hash[::Symbol, untyped]
.sentences(text, **options) ⇒ ::Array[::String]
43
|
# File 'lib/twfilter.rb', line 43
def sentences(text, **options) = Sentences.split(text, **options)
|