<commit_before>require 'ruby_speech/grxml/match'
require 'ruby_speech/grxml/no_match'
require 'ruby_speech/grxml/potential_match'
require 'ruby_speech/grxml/max_match'
require 'ruby_speech/ruby_speech'

if RUBY_PLATFORM =~ /java/
  require 'jruby'
  com.benlangfeld.ruby_speech.RubySpeechService.new.basicLoad(JRuby.runtime)
end

module RubySpeech
  module GRXML
    class Matcher
      UTTERANCE_CONVERTER = Hash.new { |hash, key| hash[key] = key }
      UTTERANCE_CONVERTER['*'] = 'star'
      UTTERANCE_CONVERTER['#'] = 'pound'

      attr_reader :grammar

      def initialize(grammar)
        @grammar = grammar
        prepare_grammar
        compile_regex regexp_content
      end

      ##
      # Checks the grammar for a match against an input string
      #
      # @param [String] other the input string to check for a match with the grammar
      #
      # @return [NoMatch, PotentialMatch, Match, MaxMatch] depending on the result of a match attempt. A potential match indicates that the buffer is valid, but incomplete. A MaxMatch is differentiated from a Match in that it cannot accept further input. If a match can be found, it will be returned with appropriate mode/confidence/utterance and interpretation attributes
      #
      # @example A grammar that takes a 4 digit pin terminated by hash, or the *9 escape sequence
      #     ```ruby
      #       grammar = RubySpeech::GRXML.draw :mode => :dtmf, :root => 'pin' do<commit_msg>[BUGFIX] Get back Java 1.6 compatibility<commit_after>require 'ruby_speech/grxml/match'
require 'ruby_speech/grxml/no_match'
require 'ruby_speech/grxml/potential_match'
require 'ruby_speech/grxml/max_match'
require 'ruby_speech/ruby_speech'

if RUBY_PLATFORM =~ /java/
  require 'jruby'
  com.benlangfeld.ruby_speech.RubySpeechService.new.basicLoad(JRuby.runtime)
end

module RubySpeech
  module GRXML
    class Matcher
      UTTERANCE_CONVERTER = Hash.new { |hash, key| hash[key] = key }
      UTTERANCE_CONVERTER['*'] = 'star'
      UTTERANCE_CONVERTER['#'] = 'pound'

      attr_reader :grammar

      def initialize(grammar)
        @grammar = grammar
        prepare_grammar
        compile_regex regexp_content.gsub(/\?<[\w\d\s]*>/, '')
      end

      ##
      # Checks the grammar for a match against an input string
      #
      # @param [String] other the input string to check for a match with the grammar
      #
      # @return [NoMatch, PotentialMatch, Match, MaxMatch] depending on the result of a match attempt. A potential match indicates that the buffer is valid, but incomplete. A MaxMatch is differentiated from a Match in that it cannot accept further input. If a match can be found, it will be returned with appropriate mode/confidence/utterance and interpretation attributes
      #
      # @example A grammar that takes a 4 digit pin terminated by hash, or the *9 escape sequence
      #     ```ruby
      #       grammar = RubySpeech::GRXML.draw :mode => :dtmf, :root => 'pin' do
{'fraction_non_alphanumeric': 0.08415005069280163, 'fraction_numerical': 0.002027712064886786, 'mean_word_length': 3.321167883211679, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4129891', 'n_tokens_mistral': 945, 'n_tokens_neox': 863, 'n_words': 298}