Class: Glaemscribe::API::TranscriptionPostProcessor

Inherits:
TranscriptionPrePostProcessor show all
Defined in:
lib/api/transcription_pre_post_processor.rb

Instance Attribute Summary collapse

Attributes inherited from TranscriptionPrePostProcessor

#operators, #root_code_block

Instance Method Summary collapse

Methods inherited from TranscriptionPrePostProcessor

#descend_if_tree, #finalize, #initialize

Constructor Details

This class inherits a constructor from Glaemscribe::API::TranscriptionPrePostProcessor

Instance Attribute Details

#out_spaceObject

Returns the value of attribute out_space.



121
122
123
# File 'lib/api/transcription_pre_post_processor.rb', line 121

def out_space
  @out_space
end

Instance Method Details

#apply(tokens, out_charset) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/api/transcription_pre_post_processor.rb', line 123

def apply(tokens, out_charset)
  
  out_space_str     = " "
  out_space_str     = @out_space.map{ |token| out_charset[token].str }.join("") if @out_space
   
  # Apply filters
  @operators.each{ |operator|
    tokens = operator.apply(tokens,out_charset)
  } 
  
  # Convert output
  ret = ""
  tokens.each{ |token|
    case token 
      when ""
      when "*UNKNOWN"
         ret += UNKNOWN_CHAR_OUTPUT
      when "*SPACE"
          ret += out_space_str
      when "*LF"
         ret += "\n"
      else
        c = out_charset[token]       
        ret += (c.nil?)?(UNKNOWN_CHAR_OUTPUT):c.str
    end        
  }
  ret
end