private void ChangeComparisonType()
        {
            DataResult <Settings> dataResult = Config.RetrieveSettings();

            if (dataResult.MainResult.Success)
            {
                ComparisonType type = dataResult.Data.ComparisonType;
                WriteLine($"Current Setting For Comparison Type: {type.ToString()}");
                string name = Enum.GetNames(typeof(ComparisonType))
                              .Where(x => !x.Equals(type.ToString(), StringComparison.InvariantCultureIgnoreCase))
                              .First();
                ComparisonType nextType = (ComparisonType)Enum.Parse(typeof(ComparisonType), name);
                Write($"Do you want to change comparison type to `{name}` ? [Y|N]> ");

                string confirm = ReadLine();
                while ((!confirm.Equals("y", StringComparison.InvariantCultureIgnoreCase) &&
                        !confirm.Equals("n", StringComparison.InvariantCultureIgnoreCase)))
                {
                    Write($"Do you want to change comparison type to `{name}` ? [Y|N]> ");
                    confirm = ReadLine();
                }
                switch (confirm.ToLower())
                {
                case "y":
                    Settings settings = dataResult.Data;
                    settings.ComparisonType = nextType;
                    WriteLine("Updating settings...");
                    MainResult result = Config.StoreSettings(settings);
                    if (result.Success)
                    {
                        WriteLine("Comparison type has been changed");
                        //refresing service.....
                        WriteLine($"Refreshing service...");
                        MainResult refreshResult = _serviceController.RefreshService();
                        if (refreshResult.Success)
                        {
                            WriteLine("Service refreshed");
                        }
                        else
                        {
                            WriteLine(refreshResult.ErrorMessage);
                        }
                        //......................
                    }
                    else
                    {
                        WriteLine($"Error: `{result.ErrorMessage}`");
                    }
                    break;

                default:
                    WriteLine("Operation cancelled");
                    break;
                }
            }
            else
            {
                WriteLine($"Error: `{dataResult.MainResult.ErrorMessage}`");
            }
        }
Esempio n. 2
0
        public override IEnumerable <Argument> GetArguments()
        {
            List <Argument> args = new List <Argument>();

            args.Add(ArgumentHelper.ArgumentFactory(nameof(Response), Response));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(Treatments), Treatments));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(OtherDesignFactors), OtherDesignFactors));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(RepeatedFactor), RepeatedFactor));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(Subject), Subject));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(ResponseTransformation), ResponseTransformation));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(Covariance), Covariance));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(CompareCovarianceModels), CompareCovarianceModels));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(Covariates), Covariates));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(PrimaryFactor), PrimaryFactor));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(CovariateTransformation), CovariateTransformation));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(ANOVASelected), ANOVASelected));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(PRPlotSelected), PRPlotSelected));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(NormalPlotSelected), NormalPlotSelected));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(Significance), Significance));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(SelectedEffect), SelectedEffect));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(LSMeansSelected), LSMeansSelected));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(ComparisonType), ComparisonType.ToString()));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(GenerateComparisonsDataset), GenerateComparisonsDataset));

            return(args);
        }
Esempio n. 3
0
        public override IEnumerable <Argument> GetArguments()
        {
            List <Argument> args = new List <Argument>();

            args.Add(ArgumentHelper.ArgumentFactory(nameof(Response), Response));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(Treatments), Treatments));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(OtherDesignFactors), OtherDesignFactors));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(ResponseTransformation), ResponseTransformation));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(Covariates), Covariates));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(PrimaryFactor), PrimaryFactor));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(CovariateTransformation), CovariateTransformation));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(EquivalenceBoundsType), EquivalenceBoundsType.ToString()));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(LowerBoundAbsolute), LowerBoundAbsolute));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(UpperBoundAbsolute), UpperBoundAbsolute));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(LowerBoundPercentageChange), LowerBoundPercentageChange));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(UpperBoundPercentageChange), UpperBoundPercentageChange));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(PRPlotSelected), PRPlotSelected));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(NormalPlotSelected), NormalPlotSelected));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(Significance), Significance));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(SelectedEffect), SelectedEffect));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(LSMeansSelected), LSMeansSelected));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(ComparisonType), ComparisonType.ToString()));
            args.Add(ArgumentHelper.ArgumentFactory(nameof(ControlGroup), ControlGroup));

            return(args);
        }
Esempio n. 4
0
        public static string ComparisonString(ComparisonType comparison)
        {
            switch (comparison)
            {
            case ComparisonType.None:
                return("");

            case ComparisonType.NotEquals:
                return("!");

            case ComparisonType.Equals:
                return("=");

            case ComparisonType.ExactlyEquals:
                return("==");

            case ComparisonType.LessThan:
                return("<");

            case ComparisonType.LessThanOrEquals:
                return("<=");

            case ComparisonType.GreaterThan:
                return(">");

            case ComparisonType.GreaterThanOrEquals:
                return(">=");
            }
            throw new NotImplementedException(comparison.ToString());
        }
Esempio n. 5
0
        /// <summary>Sets the expression.</summary>
        /// <param name="field">The field.</param>
        /// <param name="value">The value.</param>
        /// <param name="comparison">The comparison.</param>
        public void SetExpression(SearchField field, string value, ComparisonType comparison)
        {
            if (!string.IsNullOrEmpty(value) && Enum.IsDefined(typeof(SearchField), field) && Enum.IsDefined(typeof(ComparisonType), comparison))
            {
                Expression = "{'" + field.ToString() + "': {'" + comparison.ToString() + "': '" + value + "'}}";

                Value = value;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Returns the client validation rules.
        /// </summary>
        /// <param name="metadata">The model metadata of the object being validated.</param>
        /// <param name="context">The controller context.</param>
        /// <returns>The client validation rules.</returns>
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            var clientValidationRule = new ModelClientValidationRule()
            {
                ErrorMessage   = FormatErrorMessage(metadata.GetDisplayName(), GetOtherDisplayName(metadata.AdditionalValues["ParentModel"])),
                ValidationType = string.Format("is{0}", ComparisonType.ToString().ToLower())
            };

            clientValidationRule.ValidationParameters.Add("dependentproperty", DependentProperty);
            clientValidationRule.ValidationParameters.Add("comparisontype", ComparisonType);
            clientValidationRule.ValidationParameters.Add("passonnull", PassOnNull.ToString().ToLowerInvariant());
            clientValidationRule.ValidationParameters.Add("failonnull", FailOnNull.ToString().ToLowerInvariant());

            return(new[] { clientValidationRule });
        }
Esempio n. 7
0
        public override string GetCommandLineArguments()
        {
            ArgumentFormatter argFormatter = new ArgumentFormatter();
            StringBuilder     arguments    = new StringBuilder();

            //first thing to do is to assemble the model (use the GetModel method)
            arguments.Append(" " + argFormatter.GetFormattedArgument(GetModel(), true));     //4

            arguments.Append(" " + argFormatter.GetFormattedArgument(RepeatedFactor, true)); //5

            arguments.Append(" " + argFormatter.GetFormattedArgument(Subject, true));        //6

            //assemble a model for the covariate plot (if a covariate has been chosen)...
            arguments.Append(" " + argFormatter.GetFormattedArgument(Covariates));                     //7

            arguments.Append(" " + argFormatter.GetFormattedArgument(Covariance, false));              //8

            arguments.Append(" " + argFormatter.GetFormattedArgument(CompareCovarianceModels));        //9

            arguments.Append(" " + argFormatter.GetFormattedArgument(ResponseTransformation, false));  //10

            arguments.Append(" " + argFormatter.GetFormattedArgument(CovariateTransformation, false)); //11

            arguments.Append(" " + argFormatter.GetFormattedArgument(PrimaryFactor, true));            //12

            arguments.Append(" " + argFormatter.GetFormattedArgument(Treatments));                     //13

            arguments.Append(" " + argFormatter.GetFormattedArgument(OtherDesignFactors));             //14

            arguments.Append(" " + argFormatter.GetFormattedArgument(ANOVASelected));                  //15
            arguments.Append(" " + argFormatter.GetFormattedArgument(PRPlotSelected));                 //16
            arguments.Append(" " + argFormatter.GetFormattedArgument(NormalPlotSelected));             //17

            arguments.Append(" " + argFormatter.GetFormattedArgument(Significance, false));            //18

            //assemble the effect model
            arguments.Append(" " + argFormatter.GetFormattedArgument(GetEffectModel(), true));           //19

            arguments.Append(" " + argFormatter.GetFormattedArgument(SelectedEffect, true));             //20

            arguments.Append(" " + argFormatter.GetFormattedArgument(LSMeansSelected));                  //21

            arguments.Append(" " + argFormatter.GetFormattedArgument(ComparisonType.ToString(), false)); //22

            arguments.Append(" " + argFormatter.GetFormattedArgument(GenerateComparisonsDataset));       //23

            return(arguments.ToString().Trim());
        }
Esempio n. 8
0
        /// <summary>
        /// 获取SQL操作符字符串
        /// </summary>
        /// <param name="comparisonType">SQL操作符</param>
        protected virtual string GetComparisonType(ComparisonType comparisonType)
        {
            switch (comparisonType)
            {
            case ComparisonType.Equals:
                return(" = ");

            case ComparisonType.NotEquals:
                return(" <> ");

            case ComparisonType.GreaterThan:
                return(" > ");

            case ComparisonType.GreaterOrEquals:
                return(" >= ");

            case ComparisonType.LessThan:
                return(" < ");

            case ComparisonType.LessOrEquals:
                return(" <= ");

            case ComparisonType.Like:
                return(" LIKE ");

            case ComparisonType.NotLike:
                return(" NOT LIKE ");

            case ComparisonType.Is:
                return(" IS ");

            case ComparisonType.IsNot:
                return(" IS NOT ");

            case ComparisonType.In:
                return(" In ");

            case ComparisonType.NotIn:
                return(" Not In ");

            case ComparisonType.BetweenAnd:
                return(" Between ");

            default:
                return(" " + comparisonType.ToString() + " ");
            }
        }
        private double Compare()
        {
            ComparisonType comparisonType = EssayComparisonManager.Instance.ComparisonType;
            string         firstEssay     = EssayComparisonManager.Instance.FisrtEssay;
            string         secondtEssay   = EssayComparisonManager.Instance.SecondEssay;

            //Send essay and max percentage to get statistics and displaying progress
            var firstEssayStatistics  = GetWordStatistics(firstEssay, 45);
            var secondEssayStatistics = GetWordStatistics(secondtEssay, 90);

            Logger.LogInfo("Comparison type is '" + comparisonType.ToString() + "'");
            Logger.LogInfo("Fisrt essay contains " + firstEssayStatistics.Count + " words.");
            Logger.LogInfo("Second essay contains " + secondEssayStatistics.Count + " words.");

            double info = 0;

            switch (comparisonType)
            {
            case ComparisonType.FullSentences:
                info = CompareFullSentences(firstEssay, secondtEssay);
                break;

            case ComparisonType.MainWordFulness:
                info = CompareMainWordFulness(firstEssayStatistics, secondEssayStatistics);
                break;

            case ComparisonType.MainWordAccuracyWithError:
                info = CompareMainWordAccuracyWithError(firstEssayStatistics, secondEssayStatistics);
                break;

            case ComparisonType.MainWordAccuracyWithSignificanceKoefficient:
                info = CompareMainWordAccuracyWithSignificanceCoefficient(firstEssayStatistics, secondEssayStatistics);
                break;

            default:
                info = CompareMainWordFulness(firstEssayStatistics, secondEssayStatistics);
                break;
            }

            return(info);
        }
Esempio n. 10
0
 private ItemSelector.CustomItem GetItem(Type type, Type param1, Type param2, Type returnType, MemberData data, ComparisonType operatorType)
 {
     return(new ItemSelector.CustomItem(string.Format(operatorType.ToString() + " ({0}, {1})", param1.PrettyName(), param2.PrettyName()), () => {
         NodeEditorUtility.AddNewNode(graph.editorData, null, null, mousePositionOnCanvas, (ComparisonNode n) => {
             if (param1.IsCastableTo(type))
             {
                 n.targetA = data;
                 n.targetB = new MemberData(ReflectionUtils.CreateInstance(param1));
             }
             else
             {
                 n.targetA = new MemberData(ReflectionUtils.CreateInstance(param2));
                 n.targetB = data;
             }
             n.operatorType = operatorType;
             graph.Refresh();
         });
     }, "Operator")
     {
         icon = uNodeEditorUtility.GetTypeIcon(returnType)
     });
 }
Esempio n. 11
0
        /// <summary>
        /// Builds an expression for an attribute field
        /// </summary>
        /// <param name="serviceInstance">The service instance.</param>
        /// <param name="parameterExpression">The parameter expression.</param>
        /// <param name="entityField">The property.</param>
        /// <param name="values">The values.</param>
        /// <returns></returns>
        public Expression GetAttributeExpression(IService serviceInstance, ParameterExpression parameterExpression, EntityField entityField, List <string> values)
        {
            var service = new AttributeValueService((RockContext)serviceInstance.Context);

            var attributeValues = service.Queryable().Where(v =>
                                                            v.EntityId.HasValue &&
                                                            v.Value != string.Empty);

            if (entityField.AttributeGuid.HasValue)
            {
                var attributeCache = AttributeCache.Read(entityField.AttributeGuid.Value);
                var attributeId    = attributeCache != null ? attributeCache.Id : 0;

                attributeValues = attributeValues.Where(v => v.AttributeId == attributeId);
            }
            else
            {
                attributeValues = attributeValues.Where(v => v.Attribute.Key == entityField.Name && v.Attribute.FieldTypeId == entityField.FieldType.Id);
            }

            ParameterExpression attributeValueParameterExpression = Expression.Parameter(typeof(AttributeValue), "v");

            // Determine the appropriate comparison type to use for this Expression.
            // Attribute Value records only exist for Entities that have a value specified for the Attribute.
            // Therefore, if the specified comparison works by excluding certain values we must invert our filter logic:
            // first we find the Attribute Values that match those values and then we exclude the associated Entities from the result set.
            var            comparisonType          = ComparisonType.EqualTo;
            ComparisonType evaluatedComparisonType = comparisonType;

            if (values.Count >= 2)
            {
                string comparisonValue = values[0];
                if (comparisonValue != "0")
                {
                    comparisonType = comparisonValue.ConvertToEnum <ComparisonType>(ComparisonType.EqualTo);
                }

                switch (comparisonType)
                {
                case ComparisonType.DoesNotContain:
                    evaluatedComparisonType = ComparisonType.Contains;
                    break;

                case ComparisonType.IsBlank:
                    evaluatedComparisonType = ComparisonType.IsNotBlank;
                    break;

                case ComparisonType.LessThan:
                    evaluatedComparisonType = ComparisonType.GreaterThanOrEqualTo;
                    break;

                case ComparisonType.LessThanOrEqualTo:
                    evaluatedComparisonType = ComparisonType.GreaterThan;
                    break;

                case ComparisonType.NotEqualTo:
                    evaluatedComparisonType = ComparisonType.EqualTo;
                    break;

                default:
                    evaluatedComparisonType = comparisonType;
                    break;
                }

                values[0] = evaluatedComparisonType.ToString();
            }

            var filterExpression = entityField.FieldType.Field.AttributeFilterExpression(entityField.FieldConfig, values, attributeValueParameterExpression);

            if (filterExpression != null)
            {
                attributeValues = attributeValues.Where(attributeValueParameterExpression, filterExpression, null);
            }

            IQueryable <int> ids = attributeValues.Select(v => v.EntityId.Value);

            MemberExpression   propertyExpression = Expression.Property(parameterExpression, "Id");
            ConstantExpression idsExpression      = Expression.Constant(ids.AsQueryable(), typeof(IQueryable <int>));
            Expression         expression         = Expression.Call(typeof(Queryable), "Contains", new Type[] { typeof(int) }, idsExpression, propertyExpression);

            // If we have used an inverted comparison type for the evaluation, invert the Expression so that it excludes the matching Entities.
            if (comparisonType != evaluatedComparisonType)
            {
                return(Expression.Not(expression));
            }
            else
            {
                return(expression);
            }
        }
        private bool CheckValuesForAccuracy(List <Po.PoData> pos, string fieldName, ComparisonType comparisonType, string comparator)
        {
            List <int> fileValues = new List <int>();

            fileValues = LoadFromFile(fieldName, comparisonType, comparator);

            if (fileValues.Count != pos.Count)
            {
                System.Diagnostics.Debug.WriteLine("CheckFailure - Po - Field: " + fieldName + " Comparison: " + comparisonType.ToString() + " Compare Value: " + comparator + " Found: " + fileValues.Count + " Expected: " + pos.Count.ToString());
                return(false);
            }

            for (int x = 0; x < fileValues.Count; x++)
            {
                if (!fileValues[x].Equals(pos[x].Id))
                {
                    System.Diagnostics.Debug.WriteLine("CheckFailure - Po Mismatch on line: " + fileValues[x].ToString());
                    return(false);
                }
            }

            System.Diagnostics.Debug.WriteLine("CheckSuccess - Po - Field: " + fieldName + " Comparison: " + comparisonType.ToString() + " Compare Value: " + comparator + " Found: " + fileValues.Count + " Expected: " + pos.Count.ToString());
            return(true);
        }
Esempio n. 13
0
        public override string GetCommandLineArguments()
        {
            ArgumentFormatter argFormatter = new ArgumentFormatter();
            StringBuilder     arguments    = new StringBuilder();

            //first thing to do is to assemble the model (use the GetModel method)
            arguments.Append(" " + argFormatter.GetFormattedArgument(GetModel(), true)); //4

            string scatterplotModel = argFormatter.GetFormattedArgument(Response + "~scatterPlotColumn", true);

            arguments.Append(" " + scatterplotModel); //5

            //assemble a model for the covariate plot (if a covariate has been chosen)...
            arguments.Append(" " + argFormatter.GetFormattedArgument(Covariates)); //6

            //get transforms
            arguments.Append(" " + argFormatter.GetFormattedArgument(ResponseTransformation, false));    //7

            arguments.Append(" " + argFormatter.GetFormattedArgument(CovariateTransformation, false));   //8

            arguments.Append(" " + argFormatter.GetFormattedArgument(PrimaryFactor, true));              //9

            arguments.Append(" " + argFormatter.GetFormattedArgument(Treatments));                       //10

            arguments.Append(" " + argFormatter.GetFormattedArgument(OtherDesignFactors));               //11

            arguments.Append(" " + argFormatter.GetFormattedArgument(EquivalenceBoundsType.ToString())); //12

            if (EquivalenceBoundsType == EquivalenceBoundsOption.Absolute)
            {
                arguments.Append(" " + argFormatter.GetFormattedArgument(LowerBoundAbsolute)); //13
                arguments.Append(" " + argFormatter.GetFormattedArgument(UpperBoundAbsolute)); //14
            }
            else
            {
                arguments.Append(" " + argFormatter.GetFormattedArgument(LowerBoundPercentageChange)); //13
                arguments.Append(" " + argFormatter.GetFormattedArgument(UpperBoundPercentageChange)); //14
            }

            arguments.Append(" " + argFormatter.GetFormattedArgument(PRPlotSelected));     //15
            arguments.Append(" " + argFormatter.GetFormattedArgument(NormalPlotSelected)); //16

            arguments.Append(" " + Significance);                                          //17

            //assemble the effect model
            if (String.IsNullOrEmpty(SelectedEffect)) //18, 19
            {
                arguments.Append(" " + "NULL");
                arguments.Append(" " + "NULL");
            }
            else
            {
                arguments.Append(" " + argFormatter.GetFormattedArgument(GetEffectModel(), true));
                arguments.Append(" " + argFormatter.GetFormattedArgument(SelectedEffect, true));
            }

            arguments.Append(" " + argFormatter.GetFormattedArgument(LSMeansSelected));           //20

            arguments.Append(" " + argFormatter.GetFormattedArgument(ComparisonType.ToString())); //21

            arguments.Append(" " + argFormatter.GetFormattedArgument(ControlGroup, false));       //22

            return(arguments.ToString().Trim());
        }
Esempio n. 14
0
 public override string GetNodeName()
 {
     return(operatorType.ToString());
 }