Sha256: e6abb3db3024b5afb6d46cbb6b8d8f0c4db393362a279ccb1697c9e3c244c2c5
Contents?: true
Size: 996 Bytes
Versions: 3
Compression:
Stored size: 996 Bytes
Contents
# frozen_string_literal: true module Suika # @!visibility private class Lattice # @!visibility private Node = Struct.new(:surface, :min_cost, :min_prev, :left_id, :right_id, :cost, :attrs, keyword_init: true) attr_reader :begin_nodes, :end_nodes, :length # @!visibility private def initialize(length) @length = length @begin_nodes = Array.new(length + 1) { [] } @end_nodes = Array.new(length + 1) { [] } bos = Node.new(surface: 'BOS', left_id: 0, right_id: 0, cost: 0, attrs: []) @end_nodes[0].append(bos) eos = Node.new(surface: 'EOS', left_id: 0, right_id: 0, cost: 0, attrs: []) @begin_nodes[length].append(eos) end # @!visibility private def insert(begin_id, end_id, surface, left_id, right_id, cost, attrs) node = Node.new(surface: surface, left_id: left_id, right_id: right_id, cost: cost, attrs: attrs) @begin_nodes[begin_id].append(node) @end_nodes[end_id].append(node) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
suika-0.1.2 | lib/suika/lattice.rb |
suika-0.1.1 | lib/suika/lattice.rb |
suika-0.1.0 | lib/suika/lattice.rb |