Module: Ibex::LALR::ConflictSearchLimits
- Included in:
- ConflictSearch
- Defined in:
- lib/ibex/lalr/conflict_search_limits.rb,
sig/ibex/lalr/conflict_search_limits.rbs
Overview
Validates search limits and measures sentences against the token budget.
Constant Summary collapse
- DEFAULT_MAX_TOKENS =
32- DEFAULT_MAX_CONFIGURATIONS =
50_000
Class Method Summary collapse
Instance Method Summary collapse
- #conflict_lookahead_length ⇒ Integer
- #room_for_token?(prefix, suffix) ⇒ Boolean
- #within_token_budget?(prefix, suffix) ⇒ Boolean
Class Method Details
.validate!(max_tokens:, max_configurations:) ⇒ void
This method returns an undefined value.
11 12 13 14 |
# File 'lib/ibex/lalr/conflict_search_limits.rb', line 11 def self.validate!(max_tokens:, max_configurations:) validate_limit!(:max_tokens, max_tokens) validate_limit!(:max_configurations, max_configurations) end |
.validate_limit!(name, value) ⇒ Integer
17 18 19 20 21 |
# File 'lib/ibex/lalr/conflict_search_limits.rb', line 17 def self.validate_limit!(name, value) return value if value.is_a?(Integer) && value.positive? raise ArgumentError, "#{name} must be a positive Integer" end |
Instance Method Details
#conflict_lookahead_length ⇒ Integer
36 |
# File 'lib/ibex/lalr/conflict_search_limits.rb', line 36 def conflict_lookahead_length = @lookahead.zero? ? 0 : 1 |
#room_for_token?(prefix, suffix) ⇒ Boolean
31 32 33 |
# File 'lib/ibex/lalr/conflict_search_limits.rb', line 31 def room_for_token?(prefix, suffix) prefix.length + suffix.length + conflict_lookahead_length < @max_tokens end |
#within_token_budget?(prefix, suffix) ⇒ Boolean
26 27 28 |
# File 'lib/ibex/lalr/conflict_search_limits.rb', line 26 def within_token_budget?(prefix, suffix) prefix.length + suffix.length + conflict_lookahead_length <= @max_tokens end |