Пример #1
0
        public static int FloatMinToMaxCompare(Emotivector.Expectancy x, Emotivector.Expectancy y)
        {
            var diff = x.salience - y.salience;

            if (Math.Abs(diff) < 0.0005f)
            {
                // shortcut, handles infinities
                return(0);
            }

            return(diff < 0 ? -1 : 1);
        }
    public void ComputeUserEmotion(History history, User user)
    {
        List <Emotivector> emotivectors = new List <Emotivector>();

        // Read history and update Emotivectors
        // Add values to the emotivectors using emotivector.AddValue
        foreach (var updater in _updaters)
        {
            var emotivector = updater.Update(history, user);
            if (emotivector != null)
            {
                emotivectors.Add(emotivector);
            }
        }

        // Compute Expectancy for all the emotivectors
        List <Expectancy> expectancies = new List <Expectancy>();

        foreach (Emotivector emotivector in emotivectors)
        {
            expectancies.Add(emotivector.ComputeExpectancy());
        }

        expectancies.Sort(MathUtils.FloatMaxToMinCompare);

        // Compute emotion using expectancy
        // Compute emotion for user
        // Save expectancy for tutors
        _strongestExpectancy = null;
        if (expectancies.Count > 0)
        {
            _strongestExpectancy = expectancies[0];
            history.Set("Expectancy", _strongestExpectancy);
        }

        // Predict new values
        foreach (Emotivector emotivector in emotivectors)
        {
            emotivector.Predict();
        }
    }
Пример #3
0
 public static int FloatMaxToMinCompare(Emotivector.Expectancy x, Emotivector.Expectancy y)
 {
     return(FloatMinToMaxCompare(x, y) * -1);
 }