Class: TWFilter::Policy

Inherits:
Data
  • Object
show all
Defined in:
lib/twfilter/policy.rb,
sig/twfilter.rbs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(han_range: (1..Float::INFINITY), min_han_ratio: 0.0, max_tier: :rare, allow_latin: true, orthography_rejects: true, prc_topics_reject: false, punctuation: :wide, soft_lexicon_rejects: false, wenyan_min_han: 8, wenyan_min_hits: 2, wenyan_max_density: 0.05, block_tolerance: 0.0, evidence_per_100: 1.0) ⇒ Policy

Defaults impose no shape constraint. Literary-Chinese density fires only above 8 Han characters and 2 particle hits, since the ratio is unstable on shorter spans; 0.05 is the observed ceiling for modern prose quoting classical text. Block tolerance 0.0 rejects a window on one failing member; 1.0 evidence per 100 sentences is the floor below which a window carries no Taiwan-specific signal.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/twfilter/policy.rb', line 27

def initialize(
  han_range: (1..Float::INFINITY),
  min_han_ratio: 0.0,
  max_tier: :rare,
  allow_latin: true,
  orthography_rejects: true,
  prc_topics_reject: false,
  punctuation: :wide,
  soft_lexicon_rejects: false,
  wenyan_min_han: 8,
  wenyan_min_hits: 2,
  wenyan_max_density: 0.05,
  block_tolerance: 0.0,
  evidence_per_100: 1.0
)
  super
end

Instance Attribute Details

#allow_latinObject (readonly)

Returns the value of attribute allow_latin

Returns:

  • (Object)

    the current value of allow_latin



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def allow_latin
  @allow_latin
end

#block_toleranceObject (readonly)

Returns the value of attribute block_tolerance

Returns:

  • (Object)

    the current value of block_tolerance



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def block_tolerance
  @block_tolerance
end

#evidence_per_100Object (readonly)

Returns the value of attribute evidence_per_100

Returns:

  • (Object)

    the current value of evidence_per_100



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def evidence_per_100
  @evidence_per_100
end

#han_rangeObject (readonly)

Returns the value of attribute han_range

Returns:

  • (Object)

    the current value of han_range



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def han_range
  @han_range
end

#max_tierObject (readonly)

Returns the value of attribute max_tier

Returns:

  • (Object)

    the current value of max_tier



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def max_tier
  @max_tier
end

#min_han_ratioObject (readonly)

Returns the value of attribute min_han_ratio

Returns:

  • (Object)

    the current value of min_han_ratio



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def min_han_ratio
  @min_han_ratio
end

#orthography_rejectsObject (readonly)

Returns the value of attribute orthography_rejects

Returns:

  • (Object)

    the current value of orthography_rejects



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def orthography_rejects
  @orthography_rejects
end

#prc_topics_rejectObject (readonly)

Returns the value of attribute prc_topics_reject

Returns:

  • (Object)

    the current value of prc_topics_reject



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def prc_topics_reject
  @prc_topics_reject
end

#punctuationObject (readonly)

Returns the value of attribute punctuation

Returns:

  • (Object)

    the current value of punctuation



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def punctuation
  @punctuation
end

#soft_lexicon_rejectsObject (readonly)

Returns the value of attribute soft_lexicon_rejects

Returns:

  • (Object)

    the current value of soft_lexicon_rejects



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def soft_lexicon_rejects
  @soft_lexicon_rejects
end

#wenyan_max_densityObject (readonly)

Returns the value of attribute wenyan_max_density

Returns:

  • (Object)

    the current value of wenyan_max_density



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def wenyan_max_density
  @wenyan_max_density
end

#wenyan_min_hanObject (readonly)

Returns the value of attribute wenyan_min_han

Returns:

  • (Object)

    the current value of wenyan_min_han



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def wenyan_min_han
  @wenyan_min_han
end

#wenyan_min_hitsObject (readonly)

Returns the value of attribute wenyan_min_hits

Returns:

  • (Object)

    the current value of wenyan_min_hits



7
8
9
# File 'lib/twfilter/policy.rb', line 7

def wenyan_min_hits
  @wenyan_min_hits
end

Class Method Details

.corpusPolicy

6..60 Han characters spans a usable sentence; 0.65 Han excludes list and table fragments while admitting embedded Latin and numerals.

Returns:



50
# File 'lib/twfilter/policy.rb', line 50

def corpus = new(han_range: (6..60), min_han_ratio: 0.65)

.permissivePolicy

Returns:



65
# File 'lib/twfilter/policy.rb', line 65

def permissive = new

.publishablePolicy

Tighter bounds for material shown to learners: 40 Han is a readable card, 0.70 suppresses code-mixed text, and the 常用 chart is the pedagogical inventory.

Returns:



54
55
56
57
58
59
60
61
62
63
# File 'lib/twfilter/policy.rb', line 54

def publishable
  new(
    han_range: (6..40),
    min_han_ratio: 0.70,
    max_tier: :common,
    soft_lexicon_rejects: true,
    punctuation: :strict,
    prc_topics_reject: true
  )
end

Instance Method Details

#tier_limit::Integer

Returns:

  • (::Integer)


45
# File 'lib/twfilter/policy.rb', line 45

def tier_limit = TIERS.fetch(max_tier)

#withPolicy

Parameters:

  • (Object)

Returns:



77
# File 'sig/twfilter.rbs', line 77

def with: (**untyped) -> Policy