Esempio n. 1
0
Object model_rank_text(Object self, Object text) {
  Model::Model *model = from_ruby<Model::Model *>(self);
  string example_text = from_ruby<string>(text);
  Array indexes;
  
  vector<Classifier::Score> *ranks = model->rank_text(example_text);
  for(unsigned int i = 0; i < ranks->size(); i++)
    indexes.push(ranks->at(i).category);

  delete ranks;
  return indexes;
}
Esempio n. 2
0
Object model_rank_text_names(Object self, Object text) {
  Model::Model *model = from_ruby<Model::Model *>(self);
  string example_text = from_ruby<string>(text);
  Array names;
  
  vector<Classifier::Score> *ranks = model->rank_text(example_text);
  DataSet::NominalFeature *categories = model->data_set->category_feature();
  for(unsigned int i = 0; i < ranks->size(); i++)
    names.push(categories->names[ranks->at(i).category]);
  
  delete ranks;
  return names;
}
Esempio n. 3
0
Object quarry_rank_text_names_from_binary_model(Object path, Object text) {
  string model_path = from_ruby<string>(path);
  string example_text = from_ruby<string>(text);
  Array names;
  
  Storage::Binary reader(model_path);
  Model::Model *model = reader.read_model();
  
  vector<Classifier::Score> *ranks = model->rank_text(example_text);
  DataSet::NominalFeature *categories = model->data_set->category_feature();
  for(unsigned int i = 0; i < ranks->size(); i++)
    names.push(categories->names[ranks->at(i).category]);
  
  delete ranks;
  delete model;
  return names;
}