Class: Mitie::NERTrainer
- Inherits:
-
Object
- Object
- Mitie::NERTrainer
- Defined in:
- lib/mitie/ner_trainer.rb
Instance Method Summary collapse
- #add(instance) ⇒ Object
- #beta ⇒ Object
- #beta=(value) ⇒ Object
-
#initialize(filename) ⇒ NERTrainer
constructor
A new instance of NERTrainer.
- #num_threads ⇒ Object
- #num_threads=(value) ⇒ Object
- #size ⇒ Object
- #train ⇒ Object
Constructor Details
#initialize(filename) ⇒ NERTrainer
Returns a new instance of NERTrainer.
3 4 5 6 7 |
# File 'lib/mitie/ner_trainer.rb', line 3 def initialize(filename) raise ArgumentError, "File does not exist" unless File.exist?(filename) @pointer = FFI.mitie_create_ner_trainer(+filename) @pointer.free = FFI["mitie_free"] end |
Instance Method Details
#add(instance) ⇒ Object
9 10 11 |
# File 'lib/mitie/ner_trainer.rb', line 9 def add(instance) FFI.mitie_add_ner_training_instance(@pointer, instance.pointer) end |
#beta ⇒ Object
13 14 15 |
# File 'lib/mitie/ner_trainer.rb', line 13 def beta FFI.mitie_ner_trainer_get_beta(@pointer) end |
#beta=(value) ⇒ Object
17 18 19 20 21 |
# File 'lib/mitie/ner_trainer.rb', line 17 def beta=(value) raise ArgumentError, "beta must be greater than or equal to zero" unless value >= 0 FFI.mitie_ner_trainer_set_beta(@pointer, value) end |
#num_threads ⇒ Object
23 24 25 |
# File 'lib/mitie/ner_trainer.rb', line 23 def num_threads FFI.mitie_ner_trainer_get_num_threads(@pointer) end |
#num_threads=(value) ⇒ Object
27 28 29 |
# File 'lib/mitie/ner_trainer.rb', line 27 def num_threads=(value) FFI.mitie_ner_trainer_set_num_threads(@pointer, value) end |
#size ⇒ Object
31 32 33 |
# File 'lib/mitie/ner_trainer.rb', line 31 def size FFI.mitie_ner_trainer_size(@pointer) end |
#train ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/mitie/ner_trainer.rb', line 35 def train raise Error, "You can't call train() on an empty trainer" if size.zero? extractor = FFI.mitie_train_named_entity_extractor(@pointer) raise Error, "Unable to create named entity extractor. Probably ran out of RAM." if extractor.null? Mitie::NER.new(pointer: extractor) end |