class Pione::PNML::ConstituentRule

ConstituentRule is a class represents PIONE’s constituent rule.

Attributes

name[R]
params[R]
type[R]

Public Class Methods

new(type, name) click to toggle source

@param type [Symbol]

rule type of either `:input` or `:output`

@param name [String]

rule name
# File lib/pione/pnml/pione-model.rb, line 513
def initialize(type, name)
  @type = type
  @name = name
  @params = []
end

Public Instance Methods

as_declaration(option={}) click to toggle source

Return a declaration of constituent rule.

@return [String]

a declaration string for PIONE's constituent rule
# File lib/pione/pnml/pione-model.rb, line 523
def as_declaration(option={})
  indent("rule %s" % textize_rule_expr, option)
end

Private Instance Methods

textize_params() click to toggle source

Return a string of parameter set.

@return [String]

a string of parameter set
# File lib/pione/pnml/pione-model.rb, line 541
def textize_params
  unless @params.empty?
    @params.inject(Param.new){|res, param| res + param}.as_expr
  end
end
textize_rule_expr() click to toggle source

Return a string of rule expression.

@return [String]

a string of rule expression
# File lib/pione/pnml/pione-model.rb, line 533
def textize_rule_expr
  [@name, textize_params].compact.join(" ")
end