int cLibsvmLiveSink::myFinaliseInstance() { int ap=0; int ret = cDataSink::myFinaliseInstance(); if (ret==0) return 0; // TODO: binary model files... // load model SMILE_MSG(2,"loading LibSVM model for instance '%s' ...",getInstName()); if((model=svm_load_model(modelfile))==0) { COMP_ERR("can't open libSVM model file '%s'",modelfile); } nClasses = svm_get_nr_class(model); svmType = svm_get_svm_type(model); if(predictProbability) { if ((svmType==NU_SVR) || (svmType==EPSILON_SVR)) { nClasses = 0; SMILE_MSG(2,"LibSVM prob. model (regression) for test data: target value = predicted value + z,\nz: Laplace distribution e^(-|z|/sigma)/(2sigma),sigma=%g",svm_get_svr_probability(model)); } else { labels=(int *) malloc(nClasses*sizeof(int)); svm_get_labels(model,labels); SMILE_MSG(3,"LibSVM %i labels in model '%s':",nClasses,modelfile); int j; for(j=0;j<nClasses;j++) SMILE_MSG(3," Label[%i] : '%d'",j,labels[j]); } } //?? move this in front of above if() block ? if ((predictProbability)&&(nClasses>0)) probEstimates = (double *) malloc(nClasses*sizeof(double)); // load scale if((scale=svm_load_scale(scalefile))==0) { COMP_ERR("can't open libSVM scale file '%s'",scalefile); } // load selection loadSelection(fselection); //TODO: check compatibility of getLevelN() (possibly after selection), number of features in model, and scale if (nClasses>0) { // load class mapping loadClasses(classes); } else { if (classes != NULL) SMILE_IWRN(2,"not loading given class mapping file for regression SVR model (there are no classes...)!"); } return ret; }
QMap<QString, Reflection *> *ConfigLoader::load(QString const &fileName) { QDomDocument config; QFile inputFile(fileName); config.setContent(&inputFile); inputFile.close(); QFileInfo info(inputFile); // TODO: handle includes loadIncludes(config, info); loadEnums(config); loadClasses(config); loadParamsMapper(config); return &mReflections; }
void Creature::getPCListInfo(const Common::UString &bic, bool local, Common::UString &name, Common::UString &classes, Common::UString &portrait) { Aurora::GFF3File *gff = openPC(bic, local); try { const Aurora::GFF3Struct &top = gff->getTopLevel(); // Reading name const Common::UString firstName = top.getString("FirstName"); const Common::UString lastName = top.getString("LastName"); name = firstName + " " + lastName; name.trim(); // Reading portrait (failure non-fatal) try { loadPortrait(top, portrait); } catch (...) { portrait.clear(); Common::exceptionDispatcherWarning("Can't read portrait for PC \"%s\"", bic.c_str()); } // Reading classes std::vector<Class> classLevels; uint8 hitDice; loadClasses(top, classLevels, hitDice); getClassString(classLevels, classes); classes = "(" + classes + ")"; } catch (...) { delete gff; throw; } delete gff; }
void Creature::loadProperties(const Aurora::GFF3Struct &gff) { // Tag _tag = gff.getString("Tag", _tag); // Name _firstName = gff.getString("FirstName", _firstName); _lastName = gff.getString("LastName" , _lastName); _name = _firstName + " " + _lastName; _name.trim(); // Description _description = gff.getString("Description", _description); // Conversation _conversation = gff.getString("Conversation", _conversation); // Sound Set _soundSet = gff.getUint("SoundSetFile", Aurora::kFieldIDInvalid); // Gender _gender = gff.getUint("Gender", _gender); // Race _race = gff.getUint("Race", _race); // Subrace _subRace = gff.getUint("Subrace", _subRace); // PC and DM _isPC = gff.getBool("IsPC", _isPC); _isDM = gff.getBool("IsDM", _isDM); // Age _age = gff.getUint("Age", _age); // Experience _xp = gff.getUint("Experience", _xp); // Abilities _abilities[kAbilityStrength] = gff.getUint("Str", _abilities[kAbilityStrength]); _abilities[kAbilityDexterity] = gff.getUint("Dex", _abilities[kAbilityDexterity]); _abilities[kAbilityConstitution] = gff.getUint("Con", _abilities[kAbilityConstitution]); _abilities[kAbilityIntelligence] = gff.getUint("Int", _abilities[kAbilityIntelligence]); _abilities[kAbilityWisdom] = gff.getUint("Wis", _abilities[kAbilityWisdom]); _abilities[kAbilityCharisma] = gff.getUint("Cha", _abilities[kAbilityCharisma]); // Classes loadClasses(gff, _classes, _hitDice); // Skills if (gff.hasField("SkillList")) { _skills.clear(); const Aurora::GFF3List &skills = gff.getList("SkillList"); for (Aurora::GFF3List::const_iterator s = skills.begin(); s != skills.end(); ++s) { const Aurora::GFF3Struct &skill = **s; _skills.push_back(skill.getSint("Rank")); } } // Feats if (gff.hasField("FeatList")) { _feats.clear(); const Aurora::GFF3List &feats = gff.getList("FeatList"); for (Aurora::GFF3List::const_iterator f = feats.begin(); f != feats.end(); ++f) { const Aurora::GFF3Struct &feat = **f; _feats.push_back(feat.getUint("Feat")); } } // Deity _deity = gff.getString("Deity", _deity); // Health if (gff.hasField("HitPoints")) { _baseHP = gff.getSint("HitPoints"); _bonusHP = gff.getSint("MaxHitPoints", _baseHP) - _baseHP; _currentHP = gff.getSint("CurrentHitPoints", _baseHP); } // Alignment _goodEvil = gff.getUint("GoodEvil", _goodEvil); _lawChaos = gff.getUint("LawfulChaotic", _lawChaos); // Appearance _appearanceID = gff.getUint("Appearance_Type", _appearanceID); _appearanceHead = gff.getUint("Appearance_Head" , _appearanceHead); _appearanceMHair = gff.getUint("Appearance_Hair" , _appearanceMHair); _appearanceFHair = gff.getUint("Appearance_FHair", _appearanceFHair); _armorVisualType = gff.getUint("ArmorVisualType", _armorVisualType); _armorVariation = gff.getUint("Variation" , _armorVariation); if (gff.hasField("Boots")) { const Aurora::GFF3Struct &boots = gff.getStruct("Boots"); _bootsVisualType = boots.getUint("ArmorVisualType", _bootsVisualType); _bootsVariation = boots.getUint("Variation" , _bootsVariation); } // Scripts and variables readScripts(gff); readVarTable(gff); }
void Creature::loadProperties(const Aurora::GFF3Struct &gff) { // Tag _tag = gff.getString("Tag", _tag); // Name _firstName = gff.getString("FirstName", _firstName); _lastName = gff.getString("LastName" , _lastName); _name = _firstName + " " + _lastName; _name.trim(); // Description _description = gff.getString("Description", _description); // Conversation _conversation = gff.getString("Conversation", _conversation); // Sound Set _soundSet = gff.getUint("SoundSetFile", Aurora::kFieldIDInvalid); // Portrait loadPortrait(gff, _portrait); // Gender _gender = (Gender) gff.getUint("Gender", (uint64) _gender); // Race _race = gff.getUint("Race", _race); // Subrace _subRace = gff.getString("Subrace", _subRace); // PC and DM _isPC = gff.getBool("IsPC", _isPC); _isDM = gff.getBool("IsDM", _isDM); // Age _age = gff.getUint("Age", _age); // Experience _xp = gff.getUint("Experience", _xp); // Abilities _abilities[kAbilityStrength] = gff.getUint("Str", _abilities[kAbilityStrength]); _abilities[kAbilityDexterity] = gff.getUint("Dex", _abilities[kAbilityDexterity]); _abilities[kAbilityConstitution] = gff.getUint("Con", _abilities[kAbilityConstitution]); _abilities[kAbilityIntelligence] = gff.getUint("Int", _abilities[kAbilityIntelligence]); _abilities[kAbilityWisdom] = gff.getUint("Wis", _abilities[kAbilityWisdom]); _abilities[kAbilityCharisma] = gff.getUint("Cha", _abilities[kAbilityCharisma]); // Classes loadClasses(gff, _classes, _hitDice); // Skills if (gff.hasField("SkillList")) { _skills.clear(); const Aurora::GFF3List &skills = gff.getList("SkillList"); for (Aurora::GFF3List::const_iterator s = skills.begin(); s != skills.end(); ++s) { const Aurora::GFF3Struct &skill = **s; _skills.push_back(skill.getSint("Rank")); } } // Feats if (gff.hasField("FeatList")) { _feats.clear(); const Aurora::GFF3List &feats = gff.getList("FeatList"); for (Aurora::GFF3List::const_iterator f = feats.begin(); f != feats.end(); ++f) { const Aurora::GFF3Struct &feat = **f; _feats.push_back(feat.getUint("Feat")); } } // Deity _deity = gff.getString("Deity", _deity); // Health if (gff.hasField("HitPoints")) { _baseHP = gff.getSint("HitPoints"); _bonusHP = gff.getSint("MaxHitPoints", _baseHP) - _baseHP; _currentHP = gff.getSint("CurrentHitPoints", _baseHP); } // Alignment _goodEvil = gff.getUint("GoodEvil", _goodEvil); _lawChaos = gff.getUint("LawfulChaotic", _lawChaos); // Appearance _appearanceID = gff.getUint("Appearance_Type", _appearanceID); _phenotype = gff.getUint("Phenotype" , _phenotype); // Body parts for (size_t i = 0; i < kBodyPartMAX; i++) { _bodyParts[i].id = gff.getUint(kBodyPartFields[i], _bodyParts[i].id); _bodyParts[i].idArmor = 0; } // Colors _colorSkin = gff.getUint("Color_Skin", _colorSkin); _colorHair = gff.getUint("Color_Hair", _colorHair); _colorTattoo1 = gff.getUint("Color_Tattoo1", _colorTattoo1); _colorTattoo2 = gff.getUint("Color_Tattoo2", _colorTattoo2); // Equipped Items loadEquippedItems(gff); // Scripts readScripts(gff); }