Class: Glaemscribe::API::TranscriptionPostProcessor
- Inherits:
-
TranscriptionPrePostProcessor
- Object
- TranscriptionPrePostProcessor
- Glaemscribe::API::TranscriptionPostProcessor
- Defined in:
- lib/api/transcription_pre_post_processor.rb
Instance Attribute Summary collapse
-
#out_space ⇒ Object
Returns the value of attribute out_space.
Attributes inherited from TranscriptionPrePostProcessor
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_space ⇒ Object
Returns the value of attribute out_space.
122 123 124 |
# File 'lib/api/transcription_pre_post_processor.rb', line 122 def out_space @out_space end |
Instance Method Details
#apply(tokens, out_charset) ⇒ Object
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 151 152 153 154 155 156 |
# File 'lib/api/transcription_pre_post_processor.rb', line 124 def apply(tokens, out_charset) # Cleanup the output of the chain by removing empty tokens tokens.select!{ |tok| tok != "" } # Apply filters @operators.each{ |operator| tokens = operator.apply(tokens,out_charset) } out_space_str = " " out_space_str = @out_space.map{ |token| out_charset[token]&.str || UNKNOWN_CHAR_OUTPUT }.join("") if @out_space # 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 |