Class: Delphin::OutputProfileName

Inherits:
Struct
  • Object
show all
Defined in:
lib/delphin.rb

Overview

The name of a Logon TSDB output profile.

These are long strings with information about the features used to generate them in brackets.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ OutputProfileName

Create a output profile name from a directory name

Path information will be stripped from the name parameter.

name

A directory name



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/delphin.rb', line 132

def initialize(name)
  @name = File.basename(name)
  @name =~ /\[(\S+)\]\s     # 1 Prefix
            GP\[(\d+)\]\s   # 2 Grandparenting
            [+-]PT\s
            [+-]LEX\s
            CW\[(\d*)\]\s   # 3 Constituent weight
            ([+-])AE\s      # 4 Active edges
            NS\[(\d+)\]\s   # 5 N-gram size
            NT\[\w*\]\s
            ([+-])NB\s      # 6 N-gram backoff
            LM\[\d+\]\s
            FT\[:::\d+\]\s  
            RS\[\]\s
            MM\[\S+\]\s
            MI\[\d+\]\s
            RT\[(\d+(?:\.\d+)?e[+-]\d+)\]\s # 7 Relative tolerance
            AT\[\d+(?:\.\d+)?e[+-]\d+\]\s
            VA\[(\d+(?:\.\d+)?e[+-]\d+)?\]\s # 8 Variance
            PC\[\d+\]
           /x or
    raise ArgumentError.new("Invalid profile name #{name}")
  super($1, $2.to_i, $3.to_i, $4 == "+", $5.to_i, $6 == "+", $7.to_f,
        $8.nil? ? nil : $8.to_f)
end

Instance Attribute Details

#active_edgesObject

Returns the value of attribute active_edges

Returns:

  • (Object)

    the current value of active_edges



120
121
122
# File 'lib/delphin.rb', line 120

def active_edges
  @active_edges
end

#constituent_weightObject

Returns the value of attribute constituent_weight

Returns:

  • (Object)

    the current value of constituent_weight



120
121
122
# File 'lib/delphin.rb', line 120

def constituent_weight
  @constituent_weight
end

#grandparentingObject

Returns the value of attribute grandparenting

Returns:

  • (Object)

    the current value of grandparenting



120
121
122
# File 'lib/delphin.rb', line 120

def grandparenting
  @grandparenting
end

#nameObject (readonly)

The basename of the profile



125
126
127
# File 'lib/delphin.rb', line 125

def name
  @name
end

#ngram_back_offObject

Returns the value of attribute ngram_back_off

Returns:

  • (Object)

    the current value of ngram_back_off



120
121
122
# File 'lib/delphin.rb', line 120

def ngram_back_off
  @ngram_back_off
end

#ngram_sizeObject

Returns the value of attribute ngram_size

Returns:

  • (Object)

    the current value of ngram_size



120
121
122
# File 'lib/delphin.rb', line 120

def ngram_size
  @ngram_size
end

#prefixObject

Returns the value of attribute prefix

Returns:

  • (Object)

    the current value of prefix



120
121
122
# File 'lib/delphin.rb', line 120

def prefix
  @prefix
end

#relative_toleranceObject

Returns the value of attribute relative_tolerance

Returns:

  • (Object)

    the current value of relative_tolerance



120
121
122
# File 'lib/delphin.rb', line 120

def relative_tolerance
  @relative_tolerance
end

#varianceObject

Returns the value of attribute variance

Returns:

  • (Object)

    the current value of variance



120
121
122
# File 'lib/delphin.rb', line 120

def variance
  @variance
end

Instance Method Details

#equal_learner_features?(other) ⇒ Boolean

Do this profile name and other have the all same machine learning features?

Returns:

  • (Boolean)


164
165
166
167
168
169
# File 'lib/delphin.rb', line 164

def equal_learner_features?(other)
  [:grandparenting, :constituent_weight, :active_edges, :ngram_size,
   :ngram_back_off, :relative_tolerance, :variance].all? do |feature|
    send(feature) == other.send(feature)
  end
end

#feature_stringObject

A compact and readable representation of all the feature values.



172
173
174
175
176
177
# File 'lib/delphin.rb', line 172

def feature_string
  [:grandparenting, :constituent_weight, :active_edges, :ngram_size,
   :ngram_back_off, :relative_tolerance, :variance].collect do |feature|
    "#{feature.to_s}=#{send(feature)}"
  end.join(",")
end

#to_sObject



158
159
160
# File 'lib/delphin.rb', line 158

def to_s
  "#{prefix}:#{feature_string}"
end