Class: Gliner::ConfigParser

Inherits:
Object
  • Object
show all
Defined in:
lib/gliner/config_parser.rb

Instance Method Summary collapse

Instance Method Details

#build_field_descriptions(parsed_fields) ⇒ Object



21
22
23
# File 'lib/gliner/config_parser.rb', line 21

def build_field_descriptions(parsed_fields)
  Config::FieldSpec.build_descriptions(parsed_fields)
end

#build_prompt(base, label_descriptions) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/gliner/config_parser.rb', line 25

def build_prompt(base, label_descriptions)
  prompt = base.to_s

  label_descriptions.to_h.each do |label, description|
    next if description.to_s.empty?

    prompt += " [DESCRIPTION] #{label}: #{description}"
  end

  prompt
end

#parse_classification_task(task_name, config) ⇒ Object



13
14
15
# File 'lib/gliner/config_parser.rb', line 13

def parse_classification_task(task_name, config)
  Config::ClassificationTask.parse(task_name, config)
end

#parse_entity_types(entity_types) ⇒ Object



9
10
11
# File 'lib/gliner/config_parser.rb', line 9

def parse_entity_types(entity_types)
  Config::EntityTypes.parse(entity_types)
end

#parse_field_spec(spec) ⇒ Object



17
18
19
# File 'lib/gliner/config_parser.rb', line 17

def parse_field_spec(spec)
  Config::FieldSpec.parse(spec)
end