Sha256: bd76b2a86d2afee46cf74251e769e4f9fb081c56fa15cf6c6df5f11a828913c5
Contents?: true
Size: 798 Bytes
Versions: 3
Compression:
Stored size: 798 Bytes
Contents
module Sequitur # Module for classes implementing the Sequitur algorithm # A digram is a sequence of two grammar symbols (terminal or not). class Digram # The sequence of two consecutive grammar symbols. attr_reader(:symbols) # The object id of the production that contains this digram in its rhs. attr_reader(:production_id) # An unique Hash key of the digram attr_reader(:key) # Constructor. def initialize(symbol1, symbol2, aProduction) @symbols = [symbol1, symbol2] @key = "#{symbol1.hash.to_s(16)}:#{symbol2.hash.to_s(16)}" @production_id = aProduction.object_id end # Return the production object of this digram def production() ObjectSpace._id2ref(production_id) end end # class end # module # End of file
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sequitur-0.0.06 | lib/sequitur/digram.rb |
sequitur-0.0.05 | lib/sequitur/digram.rb |
sequitur-0.0.04 | lib/sequitur/digram.rb |