Class: Quarry::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/quarry_rb/model/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(m = nil) ⇒ Model

Returns a new instance of Model.



4
5
6
# File 'lib/quarry_rb/model/model.rb', line 4

def initialize(m = nil)
  @model = m || Quarry::ImplModel.new
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



3
4
5
# File 'lib/quarry_rb/model/model.rb', line 3

def model
  @model
end

Instance Method Details

#add_text_example(text, category_name) ⇒ Object



54
55
56
# File 'lib/quarry_rb/model/model.rb', line 54

def add_text_example(text, category_name)
  @model.add_text_example(text, category_name)
end

#classifier=(c) ⇒ Object

def classifier

@model.get_classifier

end



21
22
23
# File 'lib/quarry_rb/model/model.rb', line 21

def classifier=(c)
  @model.set_classifier(c.classifier)
end

#classify(example) ⇒ Object



42
43
44
# File 'lib/quarry_rb/model/model.rb', line 42

def classify(example)
  @model.classify(example)
end

#classify_text(text) ⇒ Object



46
47
48
# File 'lib/quarry_rb/model/model.rb', line 46

def classify_text(text)
  @model.classify_text(text)
end

#data_setObject



8
9
10
# File 'lib/quarry_rb/model/model.rb', line 8

def data_set
  @data_set ||= Quarry::DataSet::DataSet.new(@model.get_data_set)
end

#data_set=(ds) ⇒ Object



12
13
14
15
# File 'lib/quarry_rb/model/model.rb', line 12

def data_set=(ds)
  @model.set_data_set(ds.data_set)
  @data_set = ds
end

#process_text(text, create_features = true) ⇒ Object



50
51
52
# File 'lib/quarry_rb/model/model.rb', line 50

def process_text(text, create_features = true)
  DataSet::Example.new(@model.process_text(text, create_features), data_set)
end

#rank(example) ⇒ Object



58
59
60
# File 'lib/quarry_rb/model/model.rb', line 58

def rank(example)
  @model.rank(example)
end

#rank_text(text) ⇒ Object



62
63
64
# File 'lib/quarry_rb/model/model.rb', line 62

def rank_text(text)
  @model.rank_text(text)
end

#rank_text_names(text) ⇒ Object



66
67
68
# File 'lib/quarry_rb/model/model.rb', line 66

def rank_text_names(text)
  @model.rank_text_names(text)
end

#text_pipelineObject



25
26
27
# File 'lib/quarry_rb/model/model.rb', line 25

def text_pipeline
  @text_pipeline ||= TextPipeline.new(@model.get_text_pipeline)
end

#text_pipeline=(t) ⇒ Object



29
30
31
32
# File 'lib/quarry_rb/model/model.rb', line 29

def text_pipeline=(t)
  @model.set_text_pipeline(t.text_pipeline)
  @text_pipeline = t
end

#train(example) ⇒ Object



34
35
36
# File 'lib/quarry_rb/model/model.rb', line 34

def train(example)
  @model.train(example)
end

#train_text(text) ⇒ Object



38
39
40
# File 'lib/quarry_rb/model/model.rb', line 38

def train_text(text)
  @model.train_text(text)
end