public SelectionResult Select(Dictionary <string, string> jsonModelsToIds, List <int> sequence)
        {
            List <string>          errors = new List <string>();
            List <IHsmModelHolder> models = new List <IHsmModelHolder>();

            foreach (KeyValuePair <string, string> entry in jsonModelsToIds)
            {
                IHsmModel  model     = _jsonModelFactory.CreateModel(entry.Value);
                IValidator validator = _validatorFactory.CreateModelValidator(model);
                validator.Validate();
                if (validator.HasErrors())
                {
                    errors.AddRange(validator.GetErrors());
                    continue;
                }
                else
                {
                    models.Add(new HsmModelHolder(entry.Key, model));
                }
            }

            if (errors.Count > 0)
            {
                return(SelectionResult.Failure(errors));
            }

            IModelSelector  modelSelector = _modelSelectorFactory.CreateModelSelector(_modelSelectorType, _selectionCriterionType);
            IHsmModelHolder selectedModel = modelSelector.Select(sequence, models);

            return(SelectionResult.Success(selectedModel.Name));
        }
Exemple #2
0
 public MatcherModel(IModelSelector selector, IModelStorage storage)
 {
     Folder = storage.Open(selector.Path);
 }
 public ClassifierModel(IModelSelector selector, IModelStorage storage)
 {
     Folder = storage.Open(selector.Path);
 }