Class: Broadlistening::SpecLoader
- Inherits:
-
Object
- Object
- Broadlistening::SpecLoader
- Defined in:
- lib/broadlistening/spec_loader.rb
Constant Summary collapse
- STEP_MAPPING =
Python版のステップ名をRuby gem用に変換するマッピング
{ "extraction" => :extraction, "embedding" => :embedding, "hierarchical_clustering" => :clustering, "hierarchical_initial_labelling" => :initial_labelling, "hierarchical_merge_labelling" => :merge_labelling, "hierarchical_overview" => :overview, "hierarchical_aggregation" => :aggregation, "hierarchical_visualization" => nil # スキップ(gem責務外) }.freeze
- OUTPUT_FILES =
Ruby gem独自の中間ファイル名
{ extraction: "extraction.json", embedding: "embeddings.json", clustering: "clustering.json", initial_labelling: "initial_labels.json", merge_labelling: "merge_labels.json", overview: "overview.json", aggregation: "result.json" }.freeze
Instance Attribute Summary collapse
-
#specs ⇒ Object
readonly
Returns the value of attribute specs.
Class Method Summary collapse
Instance Method Summary collapse
- #find(step_name) ⇒ Object
-
#initialize(specs_path) ⇒ SpecLoader
constructor
A new instance of SpecLoader.
- #steps ⇒ Object
Constructor Details
#initialize(specs_path) ⇒ SpecLoader
32 33 34 35 |
# File 'lib/broadlistening/spec_loader.rb', line 32 def initialize(specs_path) raw_specs = JSON.parse(File.read(specs_path), symbolize_names: true) @specs = convert_specs(raw_specs) end |
Instance Attribute Details
#specs ⇒ Object (readonly)
Returns the value of attribute specs.
30 31 32 |
# File 'lib/broadlistening/spec_loader.rb', line 30 def specs @specs end |
Class Method Details
.default ⇒ Object
37 38 39 |
# File 'lib/broadlistening/spec_loader.rb', line 37 def self.default new(default_specs_path) end |
.default_specs_path ⇒ Object
41 42 43 44 45 |
# File 'lib/broadlistening/spec_loader.rb', line 41 def self.default_specs_path ENV.fetch("BROADLISTENING_SPECS_PATH") do File.("../../../../../server/broadlistening/pipeline/hierarchical_specs.json", __dir__) end end |
Instance Method Details
#find(step_name) ⇒ Object
47 48 49 |
# File 'lib/broadlistening/spec_loader.rb', line 47 def find(step_name) @specs.find { |s| s[:step] == step_name.to_sym } end |
#steps ⇒ Object
51 52 53 |
# File 'lib/broadlistening/spec_loader.rb', line 51 def steps @specs.map { |s| s[:step] } end |