Module: DTW::Bands

Defined in:
lib/dtwrb/bands.rb,
sig/dtwrb.rbs

Defined Under Namespace

Modules: Unconstrained Classes: SakoeChiba

Constant Summary collapse

DEFAULT_RATIO =

Admits warping of up to a quarter of the longer sequence, the usual setting for speech.

Returns:

  • (::Float)
0.25
DEFAULT =

Returns:

SakoeChiba.new(ratio: DEFAULT_RATIO)

Class Method Summary collapse

Class Method Details

.resolve(band) ⇒ _Band

Parameters:

  • (band)

Returns:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dtwrb/bands.rb', line 30

def resolve(band)
  case band
  when Numeric
    SakoeChiba.new(ratio: band)
  when nil, :unconstrained
    Unconstrained
  when :sakoe_chiba
    DEFAULT
  else
    return band if band.respond_to?(:radius)

    raise(
      UnknownStrategyError,
      "unknown band #{band.inspect}: expected a numeric Sakoe-Chiba ratio, :sakoe_chiba, " \
        ":unconstrained or an object responding to #radius"
    )
  end
end